ActionScript 2.0 Random Boolean Function not working -
i have below code show randomly true , randomly false. in case being false. appreciated. thanks.
in below code tail , heads tow buttons.
on(release) { var guess:boolean = boolean(math.round(math.random())); var input:boolean; if (event.target.name == "tail"){ input = true; } else if (event.target.name == "heads"){ input = false; } if (guess == input){ var newresult = number(income.text) + number(amount.text); income.text = number(newresult); } else{ var newresult = number(income.text) - number(amount.text); income.text = number(newresult); } }
this work:
on(release) { var guess:boolean = boolean(math.floor(math.random()*2)); if (guess){ result.text = "your guess corrent"; var newresult = number(income.text) + number(amount.text); income.text = number(newresult); } else{ result.text = "your guess wrong"; var newresult = number(income.text) - number(amount.text); income.text = number(newresult); } }
you dont need event.target.name because function within event handler of each button. can use random boolean. event.target.name doesnt work in as2.0
Comments
Post a Comment