0

我正在尝试做一个测验。我刚刚开始使用 actionscript 3.0,所以请提供任何帮助。

所以基本上我试图让我激活或
停用它们的事件侦听器的四个按钮,我尝试过“removeEventListener”和 if 语句但是我不能让它工作。请帮帮我,谢谢。

/////////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//////////////////////////////////////////
////////////////////////////////////////////////////
4

1 回答 1

1

如果您想在单击按钮 a 后停用按钮 a,您可以这样做:

a.addEventListener(MouseEvent.CLICK, gotosomething1);
function gotosomething1 (event:MouseEvent):void
{
    gotoAndStop(89);
    a.removeEventListener(MouseEvent.CLICK, gotosomething1);
} 

编辑:

如果您想在单击按钮 yy、t 和 o 后激活按钮 a,则需要使用一些额外的变量来跟踪它们的状态。

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);
    }
}
于 2013-06-29T16:20:23.417 回答