actionscript - Guess function in Flash -
i stuck flash game. need syntax in action script below logic. game pretty large , complex explain , explain quick simple example.
i have 2 buttons. first 1 button1 , second 1 button2. when click on button1 there should guess , response guess right or wrong. it's random guess function guess right or wrong. there 2 buttons either button1 or button2 should correct per instance.
can tell me syntax in action script check random guess?
thanks in advance.
if understood question correctly should work:
button1.addeventlistener(mouseevent.click, randomguess); // event listeners button2.addeventlistener(mouseevent.click, randomguess); function randomguess(event:mouseevent):void { var guess:boolean = boolean(math.round(math.random()));//random value var input:boolean; // define input value if (event.target.name == "button1"){ input = true; // set input value } else if (event.target.name == "button2"){ input = false; } if (guess == input){ //compare input value random value trace("you guessed it."); } else{ trace("you didnt guess it."); }
}
Comments
Post a Comment