# Animated buttons, external swfs, frame labels, better code - please advise!

**URL:** <https://forum.kirupa.com/t/animated-buttons-external-swfs-frame-labels-better-code-please-advise/57436>\
**Category:** Uncategorized\
**Created:** [July 13, 2004, 6:51am UTC](https://forum.kirupa.com/t/animated-buttons-external-swfs-frame-labels-better-code-please-advise/57436 "2004-07-13T06:51:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![groundmedia](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@groundmedia](https://forum.kirupa.com/u/groundmedia)\
**Post date:** [July 13, 2004, 6:51am UTC](https://forum.kirupa.com/t/animated-buttons-external-swfs-frame-labels-better-code-please-advise/57436/1 "2004-07-13T06:51:59Z")

</div>

I have three animated buttonMc’s with code like this on them…  
[color=blue]  
on (rollOver) {gotoAndPlay(2);  
}  
on (rollOut) {gotoAndPlay(8);  
}  
on (release) {gotoAndStop(16);  
\_root.mtClip.play();  
\_root.nextMc=“scene1.swf”;  
if (\_root.butt2MC.\_currentFrame == “16”) {  
\_root.butt2MC.gotoAndPlay(8);  
}  
if (\_root.butt3MC.\_currentFrame == “16”) {  
\_root.butt3MC.gotoAndPlay(8);  
}  
\_root.statusBox.text = “button 1 text”  
}[/color]

First of all the animation works perfectly but the external swf’s can’t keep up with the user if they click too fast - how can I fix this?

Also, these buttonMC’s are on the stage but the code for them is inside each MC. The script tells each button to go to different frames to make each button animate to its appropriate state.

[[color=#22229c]look at example —\> [/color]](http://g-mg.com/example.zip)

How can I rewrite the code to …  
A) not reside in each button but on the main timeline  
B) reference frame labels instead of frame numbers  
c) not lose any functionality doing this…  
d) at least load the swf’s properly play existing outro and load new intro…

Currently If I want to add five more buttons the code must be duplicated for each buttonMC and this seems really inefficient. This is the only way I have been able to make everything work though. any insights appreciated…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 7:35am UTC](https://forum.kirupa.com/t/animated-buttons-external-swfs-frame-labels-better-code-please-advise/57436/2 "2004-07-13T07:35:42Z")

</div>

When referencing to other movie clips from the main timeline use the \_root syntax:

```auto
onClipEvent(release) {
_root.butt1MC.gotoAndPlay("myFrame");
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 5:47pm UTC](https://forum.kirupa.com/t/animated-buttons-external-swfs-frame-labels-better-code-please-advise/57436/3 "2004-07-13T17:47:06Z")

</div>

Let’s pretend there are 8 buttMC’s. butt1MC - butt8MC

[list]  
[_]on mouse over each one plays its animated rollover  
[_]on mouse out each one plays its animated rollout (back to initial state  
[_]MC is release it goes to its “down” frame and if any others are down it reverts them back to their initial state.  
[_]MC release also loads a movie into the container, plays the current movies “outro” and then plays the new movies intro  
[\*]MC release loads the dynamic text  
[/list]Right now I have the code to do this located on each button but its redundant. How can I write the code so that all of these tasks are written with the least bit of code? The code you posted is helpful in knowing the syntax but it seems I will have to write a lot of code to handle all the tasks for each button. Any ideas

> [@Fraggs](#):
>
> When referencing to other movie clips from the main timeline use the \_root syntax:
> 
> ```auto
> onClipEvent(release) {
> _root.butt1MC.gotoAndPlay("myFrame");
> }
> 
> ```
