|
Flash Methods
A Flash method is JavaScript function that is specific to Flash movies. Use Flash methods to send JavaScript calls to Flash movies from a scripting environment. Each method has a name and most methods take arguments. An argument specifies a value that the method operates upon. The calculation performed by some methods returns a value that can be used by the scripting environment.
When targeting the timeline of a movie clip within the current movie, use the same syntax in a method as you would in a Flash action. See "Assigning actions to frames " in Flash Help.
The following are the methods you can use to control a Flash movie from JavaScript. The examples are in JavaScript. The variable movie in these examples refers to an instance of the Flash movie. If the EMBED and OBJECT tags for the Flash Player movie have NAME/ID attributes set to movie, such a variable can be constructed by a statement such as:
var movie = window.document.movie
| Standard Methods |
|
|
|
Plugin Version |
|
ActiveX version |
 |
 |
|
|
GetVariable |
4, 5 |
|
4, 5 |
|
Syntax |
GetVariable( varName ) |
|
|
|
|
Description |
Returns the value of the Flash variable specified by varName. Returns null if the variable does not exist. The argument type is string. |
|
|
|
|
Example |
var firstName = movie.GetVariable("FirstName");
var radioButtonValue = movie.GetVariable("/Form/RadioButton:Value");
|
|
|
|
 |
|
|
GotoFrame |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
GotoFrame( frameNumber )
|
|
|
|
|
Description |
Activates the frame number specified by frameNumber in the current movie. If the data for a requested frame is not yet available, the player goes to the last frame available and stops, causing unexpected results during playback. Use the PercentLoaded() method to determine if enough of the movie is available to execute the GotoFrame() method.
The argument frameNumber is zero-based; that is, frameNumber is 0 in the first frame of the movie, 1 for the second frame, and so on. This differs from the Goto action within Flash, which begins at 1. The argument type is integer. |
|
|
|
|
Example |
movie.GotoFrame(24); |
|
|
|
 |
 |
|
|
IsPlaying |
2,3,4, 5 |
|
2 |
|
Syntax |
IsPlaying()
|
|
|
|
|
Description |
Returns true if the movie is currently playing. |
|
|
|
|
Example |
if (movie.IsPlaying()) { alert("movie is playing"); } |
|
|
|
 |
|
|
IsPlaying |
NA |
|
3,4, 5 |
|
Syntax |
IsPlaying()
|
|
|
|
|
Description |
Returns true if the movie is currently playing. |
|
|
|
|
Example |
if (movie.IsPlaying()) { alert("movie is playing"); } |
|
|
|
 |
|
|
LoadMovie |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
LoadMovie( layerNumber, url )
|
|
|
|
|
Description |
Loads the movie identified by url to the layer specified by layerNumber. The argument type is integer for layerNumber and string for url.
|
|
|
|
|
Example |
movie.LoadMovie(0, "mymovie.swf"); |
|
|
|
 |
|
|
Pan |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
Pan ( x, y, mode )
|
|
|
|
|
Description |
Pans a zoomed-in movie to the coordinates specified by x and y. Use mode to specify whether the values for x and y are pixels or a percent of the window. When mode is 0, the coordinates are pixels; when mode is 1, the coordinates are percent of the window. Pan does not pan beyond the boundaries of the zoomed-in movie. The argument type for all arguments is integer. |
|
|
|
|
Example |
This example pans 50% right and 50% down:
This example pans -25 pixels left and -25 pixels up:
|
|
|
|
 |
|
|
PercentLoaded |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
PercentLoaded()
|
|
|
|
|
Description |
Returns the percent of the Flash Player movie that has streamed into the browser so far; possible values are from 0 to 100. |
|
|
|
|
Example |
if (movie.PercentLoaded() == 100) { loaded = true; } |
|
|
|
 |
|
|
Play |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
Play()
|
|
|
|
|
Description |
Starts playing the movie. |
|
|
|
|
Example |
movie.Play(); |
|
|
|
 |
|
|
Rewind |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
Rewind()
|
|
|
|
|
Description |
Goes to the first frame. |
|
|
|
|
Example |
movie.Rewind(); |
|
|
|
 |
|
|
SetVariable |
4, 5 |
|
4, 5 |
|
Syntax |
SetVariable( variableName, value )
|
|
|
|
|
Description |
Sets the value of the Flash variable specified by variableName to the value specified by value. The argument type for both arguments is string. |
|
|
|
|
Example |
movie.SetVariable("/Form:UserName", "John Smith");
|
|
|
|
|
|
SetZoomRect |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
SetZoomRect ( left, top, right, bottom )
|
|
|
|
|
Description |
Zooms in on a rectangular area of the movie. The units of the coordinates are in twips (1440 units per inch). To calculate a rectangle in Flash, set the ruler units to Points and multiply the coordinates by 20 to get twips. (There are 72 points per inch.) The argument type for all arguments is integer. |
|
|
|
|
Example |
This example zooms in on a 200 x 200 pixel rectangle in the upper left corner of the movie:
var pointsToTwips = 20;
movie.SetZoomRect(0, 0, 200 * pointsToTwips, 200 * pointsToTwips);
|
|
|
|
 |
|
|
StopPlay |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
StopPlay()
|
|
|
|
|
Description |
Stops playing the movie. |
|
|
|
|
Example |
movie.StopPlay() |
|
|
|
 |
|
|
TotalFrames |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
TotalFrames()
|
|
|
|
|
Description |
Returns the total number of frames in the movie. |
|
|
|
|
Example |
var totalFrames = movie.TotalFrames(); |
|
|
|
 |
|
|
Zoom |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
Zoom( percent )
Zooms the view by a relative scale factor specified by percent. Zoom(50) doubles the size of the objects in the view. Zoom(200) reduces the size of objects in the view by one half. Zoom(0) resets the view to 100%.
You cannot specify a reduction in the size of objects in the view when the current view is already 100%. The argument type is integer. |
|
|
|
|
Example |
movie.Zoom(50); |
|
|
|
| |
|
|
|
|
|
|
| TellTarget Methods |
|
|
|
Plugin Version |
|
ActiveX version |
|
|
TCallFrame |
4, 5 |
|
4, 5 |
|
Syntax |
TCallFrame( target, frameNumber )
|
|
|
|
|
Description |
In the timeline specified by target, executes the action in the frame specified by frameNumber.
|
|
|
|
|
Example |
This example runs the actions in the fifth frame of the main timeline:
movie.TCallFrame("/", 4);
|
|
|
|
 |
|
|
TCallLabel |
4, 5 |
|
4, 5 |
|
Syntax |
TCallLabel( target, label )
|
|
|
|
|
Description |
In the Timeline indicated by target, executes the action in the frame specified by the label frame label. The argument type for both arguments is string.
|
|
|
|
|
Example |
This example runs the actions in the frame labeled HandleScriptNotify in the main timeline:
movie.TCallLabel("/", "HandleScriptNotify");
|
|
|
|
 |
|
|
TCurrentFrame |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TCurrentFrame( target )
Returns the number of the current frame for the timeline specified by target. The frame number returned is zero-based, meaning frame 1 of the Flash movie would be 0, frame 2 would be 1, and so on. The argument type is string. |
|
|
|
|
Example |
var currentFrame = movie.TCurrentFrame("/MovieClip"); |
|
|
|
 |
|
|
TCurrentLabel |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TCurrentLabel(target)]
|
|
|
|
|
Description |
Returns the label of the current frame of the timeline specified by target. If there is no current frame label, an empty string is returned. The argument type is string. |
|
|
|
|
Example |
var currentLabel = movie.TCurrentLabel("/MovieClip"); |
|
|
|
 |
|
|
TGetProperty |
4, 5 |
|
4, 5 |
|
Syntax |
TGetProperty( target, property)
|
|
|
|
|
Description |
For the timeline indicated by target, returns a string indicating the value of the property specified by property. For property, enter the integer corresponding to the desired property. For a list of all properties and their corresponding integers, see Getting and setting properties.
|
|
|
|
|
Example |
var nameIndex = 13;
var name = movie.TGetProperty("/", nameIndex);
|
|
|
|
 |
|
|
TGetPropertyAsNumber |
|
|
|
|
Syntax |
TGetPropertyAsNumber (target, property)
|
|
|
|
|
Description |
For the timeline indicated by target, returns a number indicating the value of the property specified by property. For property, enter the integer corresponding to the desired property. For a list of all properties and their corresponding integers, see Getting and setting properties.
|
|
|
|
|
Example |
var framesLoadedIndex = 12;
var framesLoaded = movie.TGetProperty("/", framesLoadedIndex);
|
|
|
|
 |
|
|
TGotoFrame |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TGotoFrame( target, frameNumber )
|
|
|
|
|
Description |
For the timeline indicated by target, goes to the frame number specified by frameNumber. The argument type for target is string. The argument type for frameNumber is integer.
|
|
|
|
|
Example |
movie.TGotoFrame("/MovieClip", 2);
|
|
|
|
 |
|
|
TGotoLabel |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TGotoLabel( target, label ) |
|
|
|
|
Description |
For the timeline indicated by target, goes to the frame label specified by label. The argument type for both arguments is string.
|
|
|
|
|
Example |
movie.TGotoLabel("/MovieClip", "MyLabel");
|
|
|
|
 |
|
|
TPlay |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TPlay( target )
|
|
|
|
|
Description |
Plays the timeline specified by target. The argument type is string.
|
|
|
|
|
Example |
movie.TPlay("/MovieClip");
|
|
|
|
|
|
TSetProperty |
4, 5 |
|
4, 5 |
|
Syntax |
TSetProperty( target, property, value)
For the timeline indicated by target, sets the value of the property specified by property to the value specified by value, which can be a string or a number. For property, enter the integer corresponding to the desired property. For a list of all properties and their corresponding integers, see Getting and setting properties. |
|
|
|
|
Example |
var visibilityIndex = 7;var nameIndex = 13;movie.TSetProperty("/MovieClip", visibilityIndex, 1);movie.TSetProperty("/MovieClip", nameIndex, "NewName"); |
|
|
|
 |
|
|
TStopPlay |
3,4, 5 |
|
3,4, 5 |
|
Syntax |
TStopPlay( target )
|
|
|
|
|
Description |
Stops the timeline specified by target. The argument type is string.
|
|
|
|
|
Example |
movie.TStopPlay("/MovieClipToStop"); |
|
|
|
| |
|
|
|
|
|
| Standard Events |
|
|
|
Plugin Version |
|
ActiveX Version |
|
|
OnProgress |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
OnProgress(percent) |
|
|
|
|
Description |
Generated as the Flash movie is downloading. The argument type is integer. |
|
|
|
|
|
|
|
|
|
|
|
OnReadyStateChange |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
OnReadyStateChange(state) |
|
|
|
|
Description |
Generated when the ready state of the control changes. The possible states are: 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete. The argument type is integer. |
|
|
|
|
|
|
|
|
|
|
|
FSCommand |
2,3,4, 5 |
|
2,3,4, 5 |
|
Syntax |
FSCommand(command, args) |
|
|
|
|
Description |
Generated when an FSCommand action is performed in the movie with a URL and the URL starts with FSCommand :. Use this to create a response to a frame or button action in the Flash movie. The argument type is string. |
|
|
|
|
|
|
|
|
|
| FSCommand for stand-alone players |
|
Plugin Version |
|
ActiveX Version |
| Quit |
2-5 |
|
2-5 |
| Fullscreen |
2-5 |
|
2-5 |
| AllowScale |
2-5 |
|
2-5 |
| Showmenu |
2-5 |
|
2-5 |
| Exec |
2-5 |
|
2-5 |
|