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
-
“My Sharona”
Frat Rock: The '70s
The Knack
06/04/11 09:27 -
“The KKK Took My Baby Away”
Anthology
The Ramones
06/04/11 09:25 -
“My Sharona”
Frat Rock: The '70s
The Knack
06/04/11 09:24