Dynamically setting Flash variables with Generator

Created Wed, 03 Jan 2001 06:02:14 +0000 Modified Wed, 03 Jan 2001 06:02:14 +0000
143 Words

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 :

  • parseInt()
  • parseFloat()

For more information check out the technote on :

Using Generator variables in Flash 5 Action Script