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; }