Flash Lite 2/2.1 has an fscommand2 called “SetInputTextType”. One of the reasons for its existence is that TextField.restrict is not supported in Flash Lite 2 / 2.1. My guess is, to make it easier for the Flash Lite Player engineers to support some forms of TextField restriction values, they found what was commonly supported on devices, and gave those as options. That way, they don’t have to write crazy parsing routines to translate your restrict values, which are typically just a string of accepted characters in a semi-RegEx like format.
Instead, you pick from 6 options like “Numeric”, “Alphanumeric”, etc. and make sure your phone actually supports the mode you are using.
For example, I’m creating a NumericStepper. Normally, one would assume you could go TextField.restrict = “0-9”. If you export for ActionScript 2 or 1, this will allow only numbers to be entered into the TextField by the user. However, as previously stated, it’s not supported in Flash Lite 2 / 2.1.
The problem with SetInputTextType, though, is that it relys on the Flash 4 targeting syntax which we all love to loathe (even though it made most of our careers). While the docs give an example, it’s on _root, and doesn’t take into account the way variables work in slash syntax vs. dot syntax. As soon as you nest yourTextField into another MovieClip, you need to take this into account.
– give your textfield’s variable property a name with a suffix of “_var”
– for the 2nd argument of SetInputTextType, go:
_target + ":" + yourTextField.variable
The _target property will hold the old slash syntax to get to your component, and the colon is used for accessing variables in slash syntax (vs. a dot like in dot syntax).
So, in my case:
__valueField.variable = "__valueField_var"; fscommand2("SetInputTextType", _target + ":" + __valueField.variable, "Numeric");
I sure hope if they make Flash Lite 3 use ActionScript 3, it also uses the ActionScript 3 clean api mentality of abandoning this slash syntax crud. Currently, it makes all the new fscommand2 calls feel legacy. Slash syntax throws me for a loop every time.