Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

stageText and number pad

Guest
Oct 07, 2011 Oct 07, 2011

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#StageTe...

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.

TOPICS
Development
9.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Oct 08, 2011 Oct 08, 2011

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;

...
Translate
Mentor ,
Oct 07, 2011 Oct 07, 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 );

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 08, 2011 Oct 08, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 08, 2011 Oct 08, 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 );

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 08, 2011 Oct 08, 2011

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 );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 10, 2011 Oct 10, 2011

Thank you so much Joe!!!

Works like a dream, and in case someone is wondering the PUNCTUATION keyboard is acutally the number keyboard that you get when you hit the 123 on a letter keyboard. The NUMBER keyboard is just 1-9 no punctuation like the phone keyboard at least in iOS.

Again thanks Joe you are making me look good in front of my boss and our client.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 10, 2011 Oct 10, 2011

Happy to help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 22, 2011 Oct 22, 2011

Being a complete novice, I may be missing something.

When I try this, I get the errors:

Definition flash.text:ReturnKeyLabel could not be found

Definition flash.text:SoftKeyboardType could not be found

Definition flash.text:StageText could not be found

Is there something else I need to do to get this to work?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2011 Oct 22, 2011

What is your player type set to? Is it either AIR 3 or a mobile player?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 22, 2011 Oct 22, 2011

The Player is set to AIR for iOS.

I see options for AIR 2.5 and 2.6. It is unclear what version of AIR for iOS this is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2011 Oct 22, 2011

At least two of the things you've used are only for AIR 3.0 or later. If you're going to use those features you would need to have overlaid AIR 3, and have that as the player type (or have iOS or Android).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 22, 2011 Oct 22, 2011

Thank-you very much.

I am downloading AIR 3 now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2011 Oct 22, 2011

Here's an article on how to overlay it:

http://kb2.adobe.com/cps/908/cpsid_90810.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 22, 2011 Oct 22, 2011

I overlayed AIR 3. Added the example code to my project and it worked the first time.

Obviously the code did not draw the text box for me, but that is easy enough.

One thing that is weird though... In the numeric input, there is no equivalent of the DONE button.

Thanks again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 25, 2013 Jun 25, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines