# \[REQ HELP\] Button code not working :(

**URL:** https://forum.kirupa.com/t/req-help-button-code-not-working/186900
**Category:** flash
**Created:** [April 25, 2006, 10:07am UTC](https://forum.kirupa.com/t/req-help-button-code-not-working/186900 "2006-04-25T10:07:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![will\_roberts](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@will\_roberts](https://forum.kirupa.com/u/will_roberts)
#### Post date: [April 25, 2006, 10:07am UTC](https://forum.kirupa.com/t/req-help-button-code-not-working/186900/1 "2006-04-25T10:07:51Z")

</div>

Hey Kirupians,

i am trying to create a mini portfolio and have come across a few problems with my code for my buttons.

i have followed the animated buttons tutorial off here and thats working great but now i want to try and use that code with code i already have for loading swf’s into a container.

This is what i have so far…

```auto

this.portButton_mc.onRollOver = function() {
 portButton_mc.gotoAndPlay("_over");
}
this.portButton_mc.onRollOut = function() {
 portButton_mc.gotoAndPlay("_out");
}

```

Now as i mentioned, the above code works great so now i want to add a onPress function that will control my swf’s in the container. now when im working with a button i can use the code

```auto

on(press){if (_root.currMovie == undefined) { 
_root.currMovie = "TITLE"; 
container.loadMovie("TITLE.swf"); 
} else if (_root.currMovie != "TITLE") { 
if (container._currentframe >= container.midframe) { 
_root.currMovie = "TITLE"; 
container.play(); 
} 
} 
}

```

And that works great but i need to add that to the movieclip button and have it work the same way. I have tried the following to no avail.

```auto

this.portButton_mc.onPress = function() {
 if (_root.currMovie == undefined) { 
_root.currMovie = "TITLE"; 
container2.loadMovie("TITLE.swf"); 
} else if (_root.currMovie != "TITLE") { 
if (container2._currentframe >= container2.midframe) { 
_root.currMovie = "TITLE"; 
container2.play(); 
} 
} 
}

```

I don’t think i am too far away but i just cant see whats going wrong. the button still animates but when i click it, it does nothing when i want it to load an swf into my container.

Please help 🙂  
Thanks in advance

---

<div class="post-metadata">

### Author: ![will\_roberts](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@will\_roberts](https://forum.kirupa.com/u/will_roberts)
#### Post date: [April 25, 2006, 11:08am UTC](https://forum.kirupa.com/t/req-help-button-code-not-working/186900/2 "2006-04-25T11:08:14Z")

</div>

Its ok i fugured it out now. i had to take the \_root out of it 🙂
