CS4, AS3 Buttons only work once
Hi,
I am trying to be good and move to AS3.
I had all of my code working, then I moved all of my main movie timeline into a movie clip (body_mc)
Main movie now has 1 frame.
My body_mc has a navigation menu, one button is portfolio_bttn which takes you to that frame label. It persists through all frames of body_mc. This button works fine.
I seem to have everything working except 4 buttons on the first frame of body_mc. They should all perform exactly the same function as portfolio_bttn. They exist only in frame 1.
They work the first time you click one (any one).
Navigate back to frame one of body_mc and all 4 buttons will no longer work. What am I doing wrong??
here is my code which is in frame 1 of the main timeline
Code:
body_mc.portfolio_bttn.addEventListener(MouseEvent.CLICK, clickPortfolio);
function clickPortfolio(event:MouseEvent):void {
body_mc.gotoAndStop("portfolio");
}
//the 4 buttons making trouble
body_mc.homeVid1_bttn.addEventListener(MouseEvent.CLICK, clickPortfolio);
body_mc.homeVid2_bttn.addEventListener(MouseEvent.CLICK, clickPortfolio);
body_mc.homeVid3_bttn.addEventListener(MouseEvent.CLICK, clickPortfolio);
body_mc.homeVid4_bttn.addEventListener(MouseEvent.CLICK, clickPortfolio);
thanks for any help
mark
1 Attachment(s)
Drop-down menu link only works once?
Quote:
Originally Posted by
sstalder
Whats happening is when your body_mc goes to frame 2, it clears out those listeners because the objects are removed from the stage at that point, then re-added when you back to frame 1 in body_mc. One frame 1 though, you are not re-adding the listeners.
I made the proper change for you.
Hey guys,
I realise this thread is a wee bit old but it's the only one I could find that pertains to my problem! I seem to be having the exact same issue. The solution to the above problem wasn't actually written here (bummer for me!) but I'm hoping someone can provide me with it.
I have a simple website with a menu bar containing 6 links. One of the links is a drop-down menu with another link inside. Everything displays properly (the drop-down animation etc.) but the link inside the drop-down only works if you click it:
1) first
2) directly after the home button (first link in the timeline) having first clicked another link in the menu - hope that makes sense?
I'm sure the problem is only a small AS3 error but because I'm very new to it, I need help to fix it!
Please help me if you can! (.fla attached)
Many thanks,
Jez.