Flash Templates Tutorials - Using MovieClip in Scripts - Names and Access Paths of the MovieClip
Names and Access Paths of the MovieClip
You can access the instance of the object by its name. Name of the clip is set in the Properties Inspector, entering the name into the field in its top left corner. The name of the needed instance of the clip can be preceded by the name of the external clip that it is built in. Sometimes there are too many of such names and in this case you need to use the access path to the movie clip. Let us suppose that the script is performed in the main movie or some built-in clip. If you want to access some property or method located in this clip(movie) you can simply state it using (this) modifier. The script to use is:
This method stops the current clip or movie. If you need to call for property or method if clip1, that is built in current clip clipMain, you must state its name:
This script expression stops the playback of the clip named clip1.
But if the script that contains this expression will be placed outside clipMain into the main movie the script will stop working. Main movie does not contain clip1, and therefore it is not assigned to it and access path will be incorrect. However, the following expression will work:
Please note, that at first we stated the name of the main clip (clipMain), where the clip1 is located, then the name of clip1, and then the needed method. We did this because clip1 is an object that is enclosed in clipMain, which in its turn is an object that is enclosed in the main movie.
If you want to access the main movie from the enclosed clip use the following modifier:
If you want to access the external object use the following modifier:
Access paths to the instances of the objects can be written in two ways. You can use absolute access path. Absolute path always starts from the main movie, absolute access path is effective when you need to address from one enclosed movie to another one that is enclosed in some other (distant) part of the movie. In this situation, absolute access path is the most effective to use.
The second way is to use the relative access path. Relative access path is written based on he location of the current clip. Relative access path is used when you need to access other clip that is located relatively close to current clip in the overall movie. Otherwise it is better to use the absolute path. You can compare two access paths below to compare each of the two ways:
You can also use gotoAndPlay and gotoAndStop methods for the MovieClip. With their help you can control the main and any of the enclosed movies.