私は最初の魚を覚えています。私はこのようなコードを見つけました。私も間違ったボタンがあります。ユーザーが間違ったボタンをクリックした場合、どのようにキャプチャできますか?
間違ったボタンのリスト:
pinkButton.addEventListener(MouseEvent.CLICK, pinkClick);
whiteButton.addEventListener(MouseEvent.CLICK, whiteClick);
greyButton.addEventListener(MouseEvent.CLICK, greyClick);
そして、私はそれが動作、黄色、赤、青をクリックした場合、私は
import flash.events.MouseEvent;
var checkString:String = "";
//Create event listeners and their functions.
YellowButton.addEventListener(MouseEvent.CLICK, yellowClick);
RedButton.addEventListener(MouseEvent.CLICK, redClick);
BlueButton.addEventListener(MouseEvent.CLICK, blueClick);
/*True choices*/
function yellowClick(evt:Event):void
{
//In each event listener function, add a letter or
//string to the checkString variable.
checkString += "y";
//Then, see if the string matches or not.
check();
}
function redClick(evt:Event):void
{
checkString += "r";
check();
}
function blueClick(evt:Event):void
{
checkString += "b";
check();
}
/*True choices*/
//If the proper sequence is red, yellow, blue, the string would read "ryb".
function check():void
{
if(checkString == "ryb")
{
//Clear the checkString for convenience before going on.
clearString();
//CODE TO GO TO NEW FRAME
gotoAndStop(3);
}
else
{
//Make sure the string is at least 3 characters long.
if(checkString.length >= 3)
{
clearString();
gotoAndStop(1);
}
}
}
function clearString():void
{
//You will want to have a function for clearing the string.
//This is especially useful if you have a button for "start over."
checkString = "";
}
このコードを使用します。どうすれば間違った選択をすることができますか?私はすべての可能性のためにコードを書く必要がありますか?プレイヤーには1チャンスがある。たとえば、プレーヤーが2つの偽と1つの真のボタン、または2つの真と1つの偽をクリックした場合、これはプレーヤーに損失をもたらします。
ありがとうdoc.iは動作していないのでそのコードを忘れています。新しいコードを使用しますが、問題があります。コードは です。 fish1.addEventListener(MouseEvent.CLICK、click1); fish2.addEventListener(MouseEvent.CLICK、click2); fish3.addEventListener(MouseEvent.CLICK、click3); fish4.addEventListener(MouseEvent.CLICK、click4); var PC:Boolean = false; function click1(m:MouseEvent){ PC = true; } function click2(m:MouseEvent){ PC = true; } function click3(m:MouseEvent){ PC = true; } function click4(m:MouseEvent){ if(PC){ PC = false; gotoAndPlay(1); } } – KucuKeko
2ボタンの真をクリックした後に進む必要があります.2ボタンが真2ボタンが偽です。 – KucuKeko
新しい質問がありますか?新しい投稿を作成する私はコメントのフォーマットされていないコードを読んでほしくないです –