Copy link to clipboard
Copied
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
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.
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;
...Copy link to clipboard
Copied
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 );
}
}
}
Copy link to clipboard
Copied
Thansk Joe, is there a version of that that can be used in the timeline code and not as a class?
Copy link to clipboard
Copied
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 );
}
Copy link to clipboard
Copied
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 );
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Happy to help.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
What is your player type set to? Is it either AIR 3 or a mobile player?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Thank-you very much.
I am downloading AIR 3 now.
Copy link to clipboard
Copied
Here's an article on how to overlay it:
http://kb2.adobe.com/cps/908/cpsid_90810.html
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now