I'm trying to do a basic rock paper scissor game for my school project that is due tomorrow since my magic 8 ball didnt work. now this is fighting me. CS5 isnt saying there are any errors but you can't even click on the objects. What am I doing wrong??
here is my script:
//This adds the mouse click event to the buttons
paper.addEventListener(MouseEvent.CLICK, chosen);
scissor.addEventListener(MouseEvent.CLICK, chosen);
rock.addEventListener(MouseEvent.CLICK, chosen);
//Array to hold the names of the paper, sissor and rock.
var choicesArray:Array = ["paper", "scissor", "rock"];
function chosen(e:Event):void{
//This is holds the player choice.
var playersChoice:String = String(e.target.name);
//This gets a random value from the choicesArray and .
var computerChoice:String = choicesArray[Math.floor(Math.random()*choicesArray.length)];
Well for starts, the "chosen" function is not an Event as you have it labeled but rather a MouseEvent. And under //player draw, remove the "else" from "else if", should only be "if". That should get it to work, somewhat... might have to work on the first conditional statement (//player wins). Said I lost when I selected paper and the computer had chosen rock. HTH.
Well for starts, the "chosen" function is not an Event as you have it labeled but rather a MouseEvent. And under //player draw, remove the "else" from "else if", should only be "if". That should get it to work, somewhat... might have to work on the first conditional statement (//player wins). Said I lost when I selected paper and the computer had chosen rock. HTH.
Thank you. I removed the Else but it still doesnt work. I still cant click on my objects nor does any of the font pop up. :/
Would you be able to save what you just created and upload it onto here? maybe i could compare and see what i did wrong?
There still is the issue however that involves the conditional statement that I had mentioned in an earlier post, but I am glad that at least it's working for you now.