Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.Event;
- paper.addEventListener(MouseEvent.CLICK, Paper);
- function Paper(e:Event):void
- {
- you.text = "You Chose Paper!";
- yourChoise = 0;
- randomComputer();
- choises();
- }
- btn_rock.addEventListener(MouseEvent.CLICK, Rock);
- function Rock(e:Event):void
- {
- you.text = "You Chose Rock!";
- yourChoise = 1;
- randomComputer();
- choises();
- }
- btn_scissor.addEventListener(MouseEvent.CLICK, Scissor);
- function Scissor(e:Event):void
- {
- you.text = "You Chose Scissor!";
- yourChoise = 2;
- randomComputer();
- choises();
- }
- var namn:Array = new Array(3);
- namn[0] = "Paper";
- namn[1] = "Rock";
- namn[2] = "Scissor";
- var yourChoise:int = 0;
- var computerChoise:int = 0;
- var myScore:int;
- var computerScore:int;
- function randomComputer():void
- {
- computerChoise = Math.random() * namn.length;
- }
- function choises():void
- {
- if (yourChoise == computerChoise)
- {
- result.text = "Tie!";
- computer.text = "Tie!";
- computerChose.text = "Computer Chose Same as You!";
- }
- if (yourChoise==0 && computerChoise==1)
- {
- result.text = "You Win!";
- textScore.text = myScore;
- myScore++;
- computer.text = "Computer Lose!";
- computerChose.text = "Computer Chose Rock!";
- }
- if (yourChoise==1 && computerChoise==0)
- {
- result.text = "You Lose!";
- computer.text = "Computer Win!";
- computerChose.text = "Computer Chose Paper!";
- }
- if (yourChoise==2 && computerChoise==0)
- {
- result.text = "You Win!";
- computer.text = "Computer Lose!";
- computerChose.text = "Computer Chose Paper!";
- }
- if (yourChoise==0 && computerChoise==2)
- {
- result.text = "You Lose!";
- computer.text = "Computer Win";
- computerChose.text = "Computer Chose Scissor!";
- }
- if (yourChoise==2 && computerChoise==1)
- {
- result.text = "You Lose!";
- computer.text = "Computer Win!";
- computerChose.text = "Computer Chose Rock!";
- }
- if (yourChoise==1 && computerChoise==2)
- {
- result.text = "You Win!";
- computer.text = "Computer Lose!";
- computerChose.text = "Computer Chose Scissor!";
- }
- }
Add Comment
Please, Sign In to add comment