Movie Clips

 < Day Day Up > 



This section looks at using Movie Clips, embedding Movie Clips inside Movie Clips, and accessing or giving instructions to these various Movie Clips.

Note 

When you export your Flash movie it becomes a SWF file. You can incorporate these movies into other movies you are developing in Flash. The movie can be imported and converted into a Movie Clip with its own Timeline. Or you can use ActionScript to tell Flash to load an external SWF movies into your movie at run time.

Before you look at the awesome power of using Movie Clips let's discuss loading movies into your main Flash movie. You can have multiple Flash movies, which play at the same time in your main movie. This is accomplished by using different levels for each movie. For instance, the main movie (the root) is level0 (zero), the bottom level. You would then use the LoadMovie action from the Actions, Browser/Network book to open another movie. The movie you wanted to open would need to be on another level such as level1, so it plays on top. If you try to open this second movie and it is on level0, it would replace the original movie. You can only have one movie per level.

The big advantage of using Movie Clips over loading movies is that a Movie Clip runs independently of the main movie. Movie Clips have their own Timelines and actions and constitute mini movies. You have a lot of control over a Movie Clip. You can change its color, position, and even make it disappear (transparency). You can also use duplicate Movie Clips and control them by assigning them different instance names.

Movie Clips are controlled by the instance name (set in the Property inspector). You add ActionScript to a Movie Clip by referencing its instance name. You can also have a Movie Clip inside of a Movie Clip. Let's look at how to communicate with your movie clips in Flash. The main Timeline is by default the root. So for instance if you wanted to add a play action it would look like this:

on (release) {      play(); }

There is no need to add the word root. But we have a Movie Clip called mymovie1. If you want to assign the play action to mymovie1 then the code would look like this:

on (release) {      mymovie1.play(); }

The addition of mymovie1 tells Flash that the Movie Clip is being played rather than the root. The dot is similar to the slash in a paths address.

Let's say we have another Movie Clip named mymovie2, which is inside the first Movie Clip. To access the embedded Movie Clip the code would look like this:

on (release) {      mymovie1.mymovie2.play(); }

Your first Movie Clip, mymovie1, is the parent of mymovie2. If you want to communicate to mymovie1 from mymovie2 the code would be

on (release) { _parent.play(); }

Now if you wanted to communicate with the main Timeline from within the Movie Clip the code would be this:

on (release) {      _root.play(); }



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net