Flash Lite 2: SetInputTextType & Slash Syntax

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.

Basic steps:

– 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.

2 Replies to “Flash Lite 2: SetInputTextType & Slash Syntax”

  1. Hi

    This dosent work for me!!
    I have tried to set up the code inside and outside my mc.
    It would be nice to have a fla to document that i really works :)

    Regards

  2. now we know that FlashLite3 is a kind of Flash8 (without bitmap stuff …) .. so we are still stuck with old skool AS2/AS1/Flash4 s**t. :-(
    anyway, thank you for the tip … :)

Comments are closed.