Reputation: 61
I am trying to make a quizz. I am just starting to get into actionscript 3.0 so please any help would be appreciated.
So basically i am trying to make the four of the buttons that i have either activate or
deactivate their event listeners, i have tried "removeEventListener" and if statements however i cannot make it work. Please help me out, thanks.
/////////navigation for t,o,y and a////////////////////////////////
a.addEventListener(MouseEvent.CLICK, gotosomething1);
function gotosomething1 (event:MouseEvent):void
{
gotoAndStop(89);
}
yy.addEventListener(MouseEvent.CLICK, gotosomething2);
function gotosomething2 (event:MouseEvent):void
{
gotoAndStop(89);
}
t.addEventListener(MouseEvent.CLICK, gotosomething3);
function gotosomething3 (event:MouseEvent):void
{
gotoAndStop(89);
}
o.addEventListener(MouseEvent.CLICK, gotosomething4);
function gotosomething4 (event:MouseEvent):void
{
gotoAndStop(89);
}
/////me trying to use the if statement for removing event listener on "a"////////
if(MouseEvent.CLICK, gotosomething2) && (MouseEvent.CLICK, gotosomething3) && (MouseEvent.CLICK, gotosomething4)
{
a.removeEventListener(MouseEvent.CLICK, gotosomething1);
}
////////////////////end//////////////////////////////////////////
////////////////////////////////////////////////////
Upvotes: 0
Views: 166
Reputation: 5459
If you want to deactivate button a after button a is clicked, you would do this:
a.addEventListener(MouseEvent.CLICK, gotosomething1);
function gotosomething1 (event:MouseEvent):void
{
gotoAndStop(89);
a.removeEventListener(MouseEvent.CLICK, gotosomething1);
}
Edit:
If you want to activate button a after buttons yy, t and o have been clicked, you would need to keep track of their statuses using some extra variables.
var yyClicked:Boolean = false;
var tClicked:Boolean = false;
var oClicked:Boolean = false;
yy.addEventListener(MouseEvent.CLICK, gotosomething2);
function gotosomething2 (event:MouseEvent):void
{
gotoAndStop(89);
yyClicked = true;
activateA();
}
t.addEventListener(MouseEvent.CLICK, gotosomething3);
function gotosomething3 (event:MouseEvent):void
{
gotoAndStop(89);
tClicked = true;
activateA();
}
o.addEventListener(MouseEvent.CLICK, gotosomething4);
function gotosomething4 (event:MouseEvent):void
{
gotoAndStop(89);
oClicked = true;
activateA();
}
function activateA()
{
if(yyClicked && tClicked && oClicked)
{
a.addEventListener(MouseEvent.CLICK, gotosomething1);
}
}
Upvotes: 1