# Problem with button functions AS2

**URL:** https://forum.kirupa.com/t/problem-with-button-functions-as2/325369
**Category:** flash
**Created:** [October 11, 2011, 9:03pm UTC](https://forum.kirupa.com/t/problem-with-button-functions-as2/325369 "2011-10-11T21:03:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Simon\_Parkinson](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Simon\_Parkinson](https://forum.kirupa.com/u/Simon_Parkinson)
#### Post date: [October 11, 2011, 9:03pm UTC](https://forum.kirupa.com/t/problem-with-button-functions-as2/325369/1 "2011-10-11T21:03:18Z")

</div>

Hello everyone,

I’ve got myself into a spot of bother. I should start be saying I don’t really qualify as a designer/developer, and I’ve got very limited experience of AS2 (and code in general). I’ve learned a little bumbling through tutorials and forums, and used one I found here to help me fade .swfs in and out of a movieclip holder. It’s a VERY old one for MX, but it seemed to do the job - [http://www.kirupa.com/developer/mx2004/transitions2.htm](http://www.kirupa.com/developer/mx2004/transitions2.htm) - only now I’m testing the site I’ve found a problem.

I’m using the code from the tutorial in a frame on my main timeline to call a functions when buttons in the bottom of a series of nested movieclips are released. When the buttons are released, the appropriate frame in associated .swf is played to fade in or out of a movieclip holder on the main timeline. Each button has a section of code like this (with all the P01button/P01/P01.swf edited as necessary)

\_root.PortraitThumbs.contentMain.P01button.onRelease = function(){  
if (\_root.currMovie == undefined) {  
\_root.currMovie = “P01”;  
container.loadMovie(“P01.swf”);  
} else if (\_root.currMovie != “P01”) {  
if (container.\_currentframe \>= container.midframe) {  
\_root.currMovie = “P01”;  
container.play();  
}  
}  
}

and the necessary code in the .swfs to be loaded in order to make the fuction work.

The weird thing is, the code works perfectly when I test the site. I navigate to the appropriate portfolio section, and the buttons fade the .swfs in and out as they should.\*\* The problem is this; when I navigate away from the portfolio section, returning to the previous level of navigation or home, then navigate back to the portfolio section, the buttons no longer work!

\*\*You can see the site online at [www.abrushwithlife.co.uk](http://www.abrushwithlife.co.uk) - it’s the Portfolio\>Landscapes/Portraits sections that are causing the bother.  
I assume each time I return to the portfolio sections the AS on the main timeline is reloaded, so is the problem that on returning to the portfolio having called these functions previously \_root.currMovie is no longer undefined, so the code no longer works? If so, how would I set it to be undefined on entering the frame?

Any ideas or help you can give would be very much appreciated. Sorry for being such a noob.

Cheers.
