![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 6.
function onUpdate() { ...statements...; }
None.
Nothing.
Event handler; onUpdate
is defined for a Live Preview movie used with a component. When an instance of a component on the Stage has a Live Preview movie, the authoring tool invokes the Live Preview movie's onUpdate
function whenever the component parameters of the component instance change. The onUpdate
function is invoked by the authoring tool with no parameters, and its return value is ignored. The onUpdate
function should be declared on the main Timeline of the Live Preview movie.
Defining an onUpdate
function in a Live Preview movie is optional.
For more information on Live Preview movies, see Using Components.
The onUpdate
function gives the Live Preview movie an opportunity to update its visual appearance to match the new values of the component parameters. When the user changes a parameter value in the components Property inspector or Component Parameters panel, onUpdate
is invoked. The onUpdate
function will do something to update itself. For instance, if the component includes a color
parameter, the onUpdate
function might alter the color of a movie clip inside the Live Preview to reflect the new parameter value. In addition, it might store the new color in an internal variable.
Here is an example of using the onUpdate
function to pass parameter values through an empty movie clip in the Live Preview movie. Suppose you have a labeled button component with a variable labelColor
, which specifies the color of the text label color. The following code is in the first frame of the main Timeline of the component movie:
//Define the textColor parameter variable to specify the color of the button label text. buttonLabel.textColor = labelColor;
In the Live Preview movie, place an empty movie clip named "xch" in the Live Preview movie. Then place the following code in the first frame of the Live Preview movie. Add "xch" to the labelColor
variable path, to pass the variable through the my_mc
movie clip:
//Write an onUpdate function, adding "my_mc." to the parameter variable names: function onUpdate (){ buttonLabel.textColor = my_mc.labelColor; }
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |