Projects
Example 3 - Multiple MovieClip Instances with Variables Assigned by Clip Events
Intro : Example 1 : Example 2 : Example 3 : Example 4
Library
- button - Movie Clip
- content - Movie Clip
- invisible - Button
Construction
- Set up the same as previous example
- Frame 1, actions layer, only
stop(); - Attach actionscript to individual instances of button movieclips using the
onClipEvent(load)handler
Actionscript
Attached to invisible button on button movieclip timeline
on(release) {
_parent.content.gotoAndStop(frame);
}
Attached to instances of button movie clip on main timeline
onClipEvent(load) {
this.text = "Home";
this.frame = 1;
}
Repeat for each button
this refers to the instance of the movie clip to which the actionscript is attached.
Advantages
- Each button has its text and content frame attached to it
- No need to keep track of instance names
Disadvantages
- Actionscript is spread out - harder to keep track of
Recently Played on iTunes
-
“Heroin”
The Velvet Underground & Nico
The Velvet Underground
11/17/08 16:26 -
“All Tomorrow's Parties”
The Velvet Underground & Nico
The Velvet Underground
11/17/08 16:20 -
“Run Run Run”
The Velvet Underground & Nico
The Velvet Underground
11/17/08 16:16