0
我工作的Adobe Flash CS5和ActionScript 3的 - 我的问题是如何让一个按钮,只可用一次,其他四个按钮已被点击点击和场景有被访问过?使用事件处理程序或类似的东西
我工作的Adobe Flash CS5和ActionScript 3的 - 我的问题是如何让一个按钮,只可用一次,其他四个按钮已被点击点击和场景有被访问过?使用事件处理程序或类似的东西
我们假设您的5个按钮始终在时间轴和上可用,它们处于顶级文档级别(如果没有,我们需要进行一些调整)。让我们还假设,从你的问题,你还没有准备好为一个文件类文件的最佳实践,所以这将是写成时间表脚本。
//assumes the 4 buttons are on the stage, named button1, button2, etc. var prerequisiteButtons:Array = [button1, button2, button3, button4]; var prerequisitesClicked:Array /*of Boolean*/ = []; coyButton.enabled = false;//your fifth button, who plays hard to get //loop through and listen for clicks on your prerequisite buttons for each (var button:DisplayObject in buttons) { button.addEventListener(MouseEvent.CLICK, checkAllClicked); } //check to see if all the buttons have been clicked function checkAllClicked(e:Event):void { //find the button in the prerequisite buttons array var buttonIndex:int = prerequisiteButtons.indexOf(e.currentTarget); //set the matching index to true in the array that keeps track of what has been clicked prerequisitesClicked[buttonIndex] = true; //count how many of them have been clicked var prerequisiteDoneCount:int = 0; for (var i:int = 0; i< prerequisitesClicked.length; i++) { if (prerequisitesClicked[i]) prerequisiteDoneCount++; } //if all the buttons have been clicked, enable the button (may also want to add a listener here) if (prerequisiteDoneCount==prerequisiteButtons.length) coyButton.enabled = true; }