In previous Director releases it was necessary to use the getVariable() and setVariable() methods to access Flash variables. Director MX 2004 now allows you to access Flash variables and execute methods directly on the Director sprite.
spriteReference.myFlashVariable = "newValue"
For example, the following expression sets the Flash variable called myColorSwatch to red on the sprite called myFlashSprite:
sprite("myFlashSprite").myColorSwatch = "red"
put spriteReference.myFlashVariable
For example, the following expression gets the value of the Flash variable called myColorSwatch on the sprite called myFlashSprite:
put sprite("myFlashSprite").myColorSwatch
spriteReference.myFlashMethod()
For example, the following expression calls the method setColorSwatch on the sprite called myFlashSprite:
sprite("myFlashSprite").setColorSwatch("blue")
For more information, see Using Flash objects in script.
You can also use the following two sprite methods to access ActionScript variables in Flash sprites: getVariable() and setVariable(). For more information, see the Scripting Reference topics in the Director Help Panel.
spriteReference.getVariable("variableName", TRUE)
The parameter TRUE is the default, and is therefore optional.
FALSE to the end of the method. This lets you get or set the value of the variable simply by using the reference.
myVariableReference = spriteReference.getVariable( "variableName", FALSE)
Once you have created the reference to the variable, you can test it with the following statement:
put myVariableReference -- value
spriteReference.setVariable( "variableName", "newValue" )
Note: Be sure to pass the Flash variable's name and value as strings in both the getVariable() and setVariable() methods. Failure to do so results in script errors when the methods are executed.