Hello.
I'm asking for some hand-holding on this one. Hopefully I can explain this well enough.
I have a complex button that when rolled over the playhead goes to Frame Label textOut.
When a roll out is executed, the playhead is to go the Frame Label textIn.
Easy enough.
mcBtnHome1.addEventListener(MouseEvent.ROLL_OVER, dropText);
function dropText (evt:MouseEvent): void
{
mcBtnHome1.gotoAndPlay("textOut");
}
mcBtnHome1.addEventListener(MouseEvent.ROLL_OUT, raiseText);
function raiseText (evt:MouseEvent): void
{
mcBtnHome1.gotoAndStop("textIn");
}
mcBtnHome1.addEventListener(MouseEvent.CLICK, landHome);
function landHome (evt:MouseEvent): void
{
mcBtnHome1.gotoAndStop("textStay");
}
The problem occurs when I plug in the third event, the click. I click the button, and the playhead moves to Frame Label textStay, as it's supposed to, but once I roll out/ off of the button, the roll out action is again executed. Once I click on the button, no more interaction is supposed to be possible.
This happens despite my having a stop(); action at the textStay frame.
I'm guessing I need an if / then of if / else statements, with some true / false declarations, but I've no clue as to what "if's" I should be checking for.
In your click function you could remove the ROLL_OUT listener, and then reassign it when you get to your textStay frame.
(Edit - actually, you probably want to assign that ROLL_OUT listener in the ROLL_OVER function at all times)
mcBtnHome1.addEventListener(MouseEvent.ROLL_OVER, dropText);
function dropText (evt:MouseEvent): void {
mcBtnHome1.addEventListener(MouseEvent.ROLL_OUT, raiseText);
mcBtnHome1.gotoAndPlay("textOut");
}
function raiseText (evt:MouseEvent): void {
mcBtnHome1.gotoAndStop("textIn");
}
mcBtnHome1.addEventListener(MouseEvent.CLICK, landHome);
function landHome (evt:MouseEvent): void {
mcBtnHome1.removeEventListener(MouseEvent.ROLL_OUT, raiseText);
mcBtnHome1.gotoAndStop("textStay");
}
North America
Europe, Middle East and Africa
Asia Pacific