Working with Movie Clips > Using actions and methods to control Timelines > About methods versus actions
About methods versus actionsTo use a methods, you invoke it by using the target path to the instance name, followed by a dot, and then the method name and arguments, as in the following statements:
myMovieClip.play();
parentClip.childClip.gotoAndPlay(3);
In the first statement, the play
method causes the myMovieClip
instance to play. In the second statement, the gotoAndPlay
method sends the playhead in childClip
(which is a child of the instance parentClip
) to frame 3 and plays.
Actions that control a Timeline have a Target parameter that specifies the target path. For example, in the following script the startDrag
action targets the customCursor
instance and makes it draggable:
on(press){ startDrag("customCursor"); }
When you use a method, you call the method at the end of the target path. For example, the following statement performs the same startDrag
function:
customCursor.startDrag();
Statements written using the MovieClip object methods tend to be more brief because they don't require the tellTarget
action. Use of the tellTarget
action is discouraged because it is not compatible with the ECMA-262 standard.
For example, to tell movie clip myMovieClip
to start playing using the MovieClip object methods, you would use the following code:
myMovieClip.play();
The following code produces the same results by using the tellTarget
action:
tellTarget ("myMovieClip") {
play();
}