“Nested movie clip”

I had already talked about “Nested movie clip” in a previous lesson but, in this lesson we will see how we can address it through “ActionScript”.

Let us take the “Flash” movie of my car again.

Meanwhile I have added a red button and green button .
One should get the car to stop and the other to let it drive.

The car is a movie clip with the instance name “car”, what did you expect?

In the “car” film clip with the instance name “car”, is another film clip with the name “wheel”.
This is called a “Nested movie clip”.
Actually this movie clip occurs twice in the “car” movie clip because you have a left wheel and right wheel. But that does not really matter for this example as long as you know what a “Nested movie clip” is.

When we test our movie (Ctrl Enter), we see that the car has stopped, but the wheels keep on turning.

By means of “Labels”, we stop when the car stops and run when the car drives.

 

“Labels”

If we add “Labels” to our frames, we can instruct “Flash” to jump to these “Labels”.

The first thing I do is to open the “car” movie clip in edit mode.
I refer to the instance of it on “Stage”.

The “car” film clip consists of three layers, “wheel_left”, “wheel_right” and “body”.

I add a new layer and name it “labels”, and in the first frame of this layer add a “Label” called “halt”.

It is wise to make a new layer for the “Label”, as for the “ActionScript” code.

Select a frame in the “labels” layer, open the “Properties window” and in the “LABEL” section you give a name for this frame. In this example I call it “halt”.

Now we return to the main “Timeline”and select frame 1 in the “AS” layer.

We click the F9 key on our keyboard to display the “Actions” menu.

Now we must add two lines, one for when the car stops, they must also stop the wheels, and one for when the car is moving, then the wheels also turn.

The first thing we should do is let “Flash” know where the movie clip is, before we want to do something.

I begin with the word “this”, meaning this film, or rather the film in which this code is located.

Are you sure you follow? We are in frame 1 of the main “Timeline”.

Then type a period and the instance name of the “Nested movie clip”, in this case it was “car”, then type a period again and type the action that “Flash” has to execute.

For the “Green” button, it is ” gotoAndPlay” and for the red button, “gotoAndStop”.

One thing plays something and the other stops something. This seems clear.

Then we put in brackets to the frame where it should go. Using a frame number, just type the number or use a frame name in quotation marks.

And finally conclude the sentence with a semicolon.

Test your movie.

This does not seem too much for “ActionScript” but, you would use this knowledge to design a whole site.

In any case if I ever have some time and there is enough interest, I will take a course to write on “ActionScript”.

 

Awesome!
You've completed Lesson 45
START NEXT LESSON