Click to See Complete Forum and Search --> : Flash timeline - button and actionscript issues


JStevensJr
05-11-2009, 04:27 PM
I am building my very first Flash web site and I am encountering problems with the buttons and actionscript.

I am tremendously appreciative of any and all advice.

The web site contains 5 pages: home, about, menu, locations and contact

When the "home" page loads, all of the buttons work just fine. But when any of the other pages load, only the "home" button works. For example, I am unable to jump directly from the "about" page to the "menu" page because those buttons only work properly when the "home" page is loaded.


link to screen grab of Flash timeline (http://www.broadcastresource.com/flash_1.jpg)

Below is the actionscript at frame 0 in the "Actions/Labels" layer:

stop();

about_btn.addEventListener(MouseEvent.CLICK, gotoABOUT);

function gotoABOUT(event:MouseEvent):void
{
gotoAndPlay(10);
}

menu_btn.addEventListener(MouseEvent.CLICK, gotoMENU);

function gotoMENU(event:MouseEvent):void
{
gotoAndPlay(20);
}

locations_btn.addEventListener(MouseEvent.CLICK, gotoLOCATIONS);

function gotoLOCATIONS(event:MouseEvent):void
{
gotoAndPlay(30);
}

contact_btn.addEventListener(MouseEvent.CLICK, gotoCONTACT);

function gotoCONTACT(event:MouseEvent):void
{
gotoAndPlay(40);
}

home_btn.addEventListener(MouseEvent.CLICK, gotoHOME);

function gotoHOME(event:MouseEvent):void
{
gotoAndPlay(1);
}



Frames 9, 19, 29, 39 and 50 contain:

stop();


Again, thank you for any and all advice!

JS

Eye for Video
05-11-2009, 05:15 PM
In order for the button actions to work for the other pages, you need to duplicate the button actionscript in each of those "stop" frames. So for each of the jump to frames stop action frame, 9, 19, 29, 39,and 50... duplicate the button actions actionscript. Then when the time reaches.. say frame 39 and stops, the button actions are available.
EfV

JStevensJr
05-11-2009, 06:52 PM
Awesome... it now works beautifully!

I had previously added (all of) the button actionscripts to each stop frame and it worked somewhat... however, it gave errors because the function names were not unique. I now realize that I should not include the button actionscript referencing the current event in the timeline.

Thank you so much for clarifying this!