Skip to main content
October 7, 2011
Answered

stageText and number pad

  • October 7, 2011
  • 2 replies
  • 9549 views

Alright Air 3.0 is out and stageText is supposed to be the answer to my problem in the app we are developing for a client.

Its a calculator app and all the inputs are numerical so I need to limit the keyboard to numbers and a decimal only. I have been looking at the very limited info available on stageText

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StageText.html#StageText%28%29

and

http://blogs.adobe.com/cantrell/archives/2011/09/native-text-input-with-stagetext.html

but I cant make any sense of it.

Can someone give me a good example, be real specific, pretend you are a talking to a 5 year old I wont be offended.

I already have dynamic input fields on the stage created with a text tool not through AS but they can be recreated with AS if need be, what do I need to do to my code to make the text boxes activate the number pad and not the keypad.

Any help would be appreciated.

This topic has been closed for replies.
Correct answer Joe ... Ward

Wait jsut watched this video Colin had made about cameraRollUI.

http://xfiles.funnygarbage.com/~colinholgate/video/camerrolltimeline.mov

Would the code look like this for the timeline?

    import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.geom.Rectangle;

    import flash.text.ReturnKeyLabel;

    import flash.text.SoftKeyboardType;

    import flash.text.StageText;

   

   

function StageTextNumber()

{

            var text:StageText = new StageText();

            text.softKeyboardType = SoftKeyboardType.NUMBER;

            text.restrict = "0-9";

            text.returnKeyLabel = ReturnKeyLabel.GO;

           

            text.stage = this.stage;

            text.viewPort = new Rectangle(10, 10, 300, 40 );

}


That should work on the timeline as long as there is something to call the function StageTextNumber().

You could also do something like:

   import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.geom.Rectangle;

    import flash.text.ReturnKeyLabel;

    import flash.text.SoftKeyboardType;

    import flash.text.StageText;

   

    

            var text:StageText = new StageText();

            text.softKeyboardType = SoftKeyboardType.NUMBER;

            text.restrict = "0-9";

            text.returnKeyLabel = ReturnKeyLabel.GO;

           

            text.stage = this.stage;

            text.viewPort = new Rectangle(10, 10, 300, 40 );

2 replies

June 25, 2013

Hi,

In FLASH Professional CS6 + CC there are no

    import flash.text.ReturnKeyLabel;

    import flash.text.SoftKeyboardType;

    import flash.text.StageText;

available to me.

Where is the StageText library?

Can I download it?

All articles everywhere state its in FLASH but it isn't.

I'm using AIR 3.8.

Any help would be great as I need custom keyboards and the type is only accessible through StageText.

Participating Frequently
October 7, 2011

The main thing to understand about StageText is that it is NOT a display object. The contents of a StageText object display in the rectangle of the stage you define with the viewPort property. To convert your existing text objects to StageText objects, you will need to remove them and create a StageText object in code positioned in the same location.

Here's an example that uses the numeric keyboard and restricts the input to numbers:

package

{

    import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.geom.Rectangle;

    import flash.text.ReturnKeyLabel;

    import flash.text.SoftKeyboardType;

    import flash.text.StageText;

   

    public class StageTextNumber extends Sprite

    {

        public function StageTextNumber()

        {

            var text:StageText = new StageText();

            text.softKeyboardType = SoftKeyboardType.NUMBER;

            text.restrict = "0-9";

            text.returnKeyLabel = ReturnKeyLabel.GO;

           

            text.stage = this.stage;

            text.viewPort = new Rectangle(10, 10, 300, 40 );

        }

    }

}

October 9, 2011

Thansk Joe, is there a version of that that can be used in the timeline code and not as a class?

October 9, 2011

Wait jsut watched this video Colin had made about cameraRollUI.

http://xfiles.funnygarbage.com/~colinholgate/video/camerrolltimeline.mov

Would the code look like this for the timeline?

    import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.geom.Rectangle;

    import flash.text.ReturnKeyLabel;

    import flash.text.SoftKeyboardType;

    import flash.text.StageText;

   

   

function StageTextNumber()

{

            var text:StageText = new StageText();

            text.softKeyboardType = SoftKeyboardType.NUMBER;

            text.restrict = "0-9";

            text.returnKeyLabel = ReturnKeyLabel.GO;

           

            text.stage = this.stage;

            text.viewPort = new Rectangle(10, 10, 300, 40 );

}