mike chambers | about

Dynamically setting Flash variables with Generator

As discussed in the previous tip of the day, you can use Generator to dynamically set the value of Action Script variables. However, you can only set a String value with Generator.

Thus to set the value of a variable :

var varName = "{genVar}";

If you want to be able to use Generator to set the value of an Action Script variable to a number / integer, then you first have to use Generator to set the value as a String and then Action Script to convert the String to a number :

For example :

var varName = int("{genVar}");

or using the non-deprecated Flash 5 code :
var varName = Number("{genVar}");

The following Action Script functions can also come in useful :

For more information check out the technote on :

Using Generator variables in Flash 5 Action Script

twitter github flickr behance