Actionscript 3 使用actionscript 3.0预设

Actionscript 3 使用actionscript 3.0预设,actionscript-3,flash,Actionscript 3,Flash,这是带有多个选择的预设变量和导航,下面的代码不是真正正确的,功能完美,没有错误,但不起作用。 var aClicked:Boolean=false; var:Boolean=false; var tClicked:Boolean=false; var oClicked:Boolean=false a.addEventListener(MouseEvent.CLICK, gotosomething1); function gotosomething1(event:MouseEvent):void

这是带有多个选择的预设变量和导航,下面的代码不是真正正确的,功能完美,没有错误,但不起作用。 var aClicked:Boolean=false; var:Boolean=false; var tClicked:Boolean=false; var oClicked:Boolean=false

a.addEventListener(MouseEvent.CLICK, gotosomething1);
function gotosomething1(event:MouseEvent):void
{
gotoAndStop(89);
yyClicked = true;
activateT();
}

yy.addEventListener(MouseEvent.CLICK, gotosomething33);
function gotosomething33(event:MouseEvent):void
{
gotoAndStop(89);
tClicked = true;
activateT();
}

o.addEventListener(MouseEvent.CLICK, gotosomethinggg);
function gotosomethinggg(event:MouseEvent):void
{
gotoAndStop(89);
oClicked = true;
activateT();
}

t.addEventListener(MouseEvent.CLICK, gotosomething99);
function gotosomething99(event:MouseEvent):void
{
gotoAndStop(89);
aClicked = true;
activateT();
}

function activateT()
{
if (aClicked && yyClicked && oClicked)
{
    t.addEventListener(MouseEvent.CLICK, gotosomething99);
}
}

yy.addEventListener(MouseEvent.CLICK, gogogo);
function gogogo(event:MouseEvent):void
{
gotoAndStop(89);
yyClicked = true;
activateYY();
}

t.addEventListener(MouseEvent.CLICK, gotosomethingplease);
function gotosomethingplease(event:MouseEvent):void
{
gotoAndStop(89);
tClicked = true;
activateYY();
}

o.addEventListener(MouseEvent.CLICK, gotoi);
function gotoi(event:MouseEvent):void
{
gotoAndStop(89);
oClicked = true;
activateYY();

}

a.addEventListener(MouseEvent.CLICK, millionare);
function millionare(event:MouseEvent):void
{
gotoAndStop(89);
aClicked = true;
activateYY();
}

function activateYY()
{
if (aClicked && tClicked && oClicked)
{
    yy.addEventListener(MouseEvent.CLICK, gogogo);
}
}

t.addEventListener(MouseEvent.CLICK, gp1);
function gp1(event:MouseEvent):void
{   
    gotoAndStop(89);
tClicked = true;
activateA();
}

a.addEventListener(MouseEvent.CLICK, gp2);
function gp2(event:MouseEvent):void
{
gotoAndStop(89);
aClicked = true;
activateA();
}

o.addEventListener(MouseEvent.CLICK, gp3);
function gp3(event:MouseEvent):void
{
gotoAndStop(89);
oClicked = true;
activateA();
}

yy.addEventListener(MouseEvent.CLICK, gp4);
function gp4(event:MouseEvent):void
{
gotoAndStop(89);
yyClicked = true;
activateA();
}

 function activateA()
{
if (yyClicked && tClicked && oClicked)
{
    a.addEventListener(MouseEvent.CLICK, gp2);
}
}

o.addEventListener(MouseEvent.CLICK, ooo);
function ooo(event:MouseEvent):void
{
gotoAndStop(89);
oClicked = true;
activateO();
}

t.addEventListener(MouseEvent.CLICK, ttt);
function ttt(event:MouseEvent):void
{
gotoAndStop(89);
tClicked = true;
activateO();
}

a.addEventListener(MouseEvent.CLICK, aaa);
function aaa(event:MouseEvent):void
{
gotoAndStop(89);
aClicked = true;
activateO();
}

yy.addEventListener(MouseEvent.CLICK, yyy);
function yyy(event:MouseEvent):void
{
gotoAndStop(89);
yyClicked = true;
activateO();
}

function activateO()
{
if (yyClicked && tClicked && aClicked)
{
    o.addEventListener(MouseEvent.CLICK, ooo);
}
}

你的问题有点不清楚。您希望在单击第三个按钮或第四个按钮时执行操作吗


在任何情况下,您都可以为每个按钮创建一个具有布尔值的字典。键是按钮,单击该按钮时,该值设置为
true
。然后,您可以计算字典中有多少个键是正数,以确定单击“足够”的时间。

这应该适用于您要查找的内容:

import flash.events.MouseEvent;
import flash.events.Event;

var btnStates:Array = [false];  // Track states for each button - works w/ any # of btns
var btnCounter:int      = 0;    // Count each Active button
var btnActivateNumber   = 4;    // The number of buttons 
this.addEventListener(MouseEvent.CLICK, btnClick);  // Click on Anything Event

function btnClick(e:Event):void
{
    var btnIndex = e.target.parent.getChildIndex(e.target);     // Btn Index

    trace("BtnIndex:", btnIndex);   // Make Sure btns are are children of same parent   
    switch(e.target.name)           // Check the name of item Clicked
    {
        case "a":   // Checks that you clicked on button and not something else
        case "yy":  // Each of these cases could be done seperately
        case "t":   // Use descriptive names when possible
        case "o":   // Add additional buttons to track if needed
            if(!btnStates[btnIndex])            // Btn not pressed before
            {
                btnCounter++;                   // Another Button Turned On
                btnStates[btnIndex] = true;     // Track Btn State

                // Add Specific code related to button ie. Animation etc.
                e.target.alpha = .75        // lighten Button
            }
            else        // Use if you want the button to turn off on 2nd press
            {
                btnCounter--;                   // Button Turned Off
                btnStates[btnIndex] = false;    // Btn State Reset for this btn
            }
        break;
        default:
            trace("OtherItemClicked:", e.target.name);  // Something else was clicked
            // If you are getting wrong item when you click on your button
            // You may have a child item in your button you will need to disable.
            // set btnName.mouseChildren = false; or item.mouseEnabled = false;
        break;
    }

    if(btnCounter == btnActivateNumber) // Test if enough buttons are pressed.
    {
        this.removeEventListener(MouseEvent.CLICK, btnClick);   // CleanUp
        trace(btnActivateNumber,"Buttons Activated");
        // Place Your Navigation Action Code Here
    }
}

我基本上希望当所有四个按钮都被点击时,导航动作就会发生。很高兴能提供帮助。我今天碰巧在做一个选择题引擎,我用它开始构建它。