Frame 1
stop();
start_btn.onRelease = function () {
gotoAndPlay (1);
};
Frame 2
function showWinningBanner() {
var _local4 = winner();
if (_local4 != undefined) {
if (_root.winBanner == undefined) {
var _local3 = this.attachMovie("WinnerBanner", "winBanner", this.getNextHighestDepth());
_local3._x = 400;
_local3._y = 300;
} else {
_root.winBanner.setObj(_local4);
}
}
}
function winner() {
if (allObj.length < maxObj) {
return(undefined);
}
var _local3;
var _local2 = 0;
while (_local2 < allObj.length) {
var _local4 = allObj[_local2];
var _local1 = _local4.getType();
if (_local1 == undefined) {
return(undefined);
}
if (_local3 == undefined) {
_local3 = _local1;
}
if (_local3 != _local1) {
return(undefined);
}
_local2++;
}
return(_local3);
}
function randomlyChooseType(movieClip) {
var _local1 = Math.random();
if (_local1 < 0.33) {
movieClip.setType("Rock");
} else if (_local1 < 0.67) {
movieClip.setType("Paper");
} else {
movieClip.setType("Scissors");
}
}
function checkCollision(movieClip, objects) {
var _local1 = 0;
while (_local1 < objects.length) {
if (objects[_local1] != movieClip) {
if (movieClip.hitTest(objects[_local1])) {
return(objects[_local1]);
}
}
_local1++;
}
return(undefined);
}
function moveObjects(objects) {
var _local7 = 0;
while (_local7 < objects.length) {
var _local1 = objects[_local7];
var _local2 = "None";
var _local3 = "None";
var _local6 = 0;
if (_local1.moveTimer != undefined) {
_local6 = _local1.moveTimer;
}
if ((_local6 == 0) || ((_local1.prevLeftRight == undefined) || (_local1.prevUpDown == undefined))) {
while ((_local2 == "None") && (_local3 == "None")) {
var _local4 = Math.random();
var _local5 = Math.random();
if (_local4 < 0.33) {
_local2 = "Up";
} else if (_local4 < 0.67) {
_local2 = "None";
} else {
_local2 = "Down";
}
if (_local5 < 0.33) {
_local3 = "Left";
} else if (_local5 < 0.67) {
_local3 = "None";
} else {
_local3 = "Right";
}
}
} else {
_local2 = _local1.prevUpDown;
_local3 = _local1.prevLeftRight;
}
if ((_local2 == "Up") && (_local1._y <= 0)) {
_local2 = "Down";
} else if ((_local2 == "Down") && (_local1._y >= stageHeight)) {
_local2 = "Up";
}
if ((_local3 == "Left") && (_local1._x <= 0)) {
_local3 = "Right";
} else if ((_local3 == "Right") && (_local1._x >= stageWidth)) {
_local3 = "Left";
}
if (_local2 == "Down") {
_local1._y = _local1._y + 1;
} else if (_local2 == "Up") {
_local1._y = _local1._y - 1;
}
if (_local3 == "Left") {
_local1._x = _local1._x - 1;
} else if (_local3 == "Right") {
_local1._x = _local1._x + 1;
}
if (_local6 == 0) {
_local1.moveTimer = moveTimerMax;
} else {
_local6--;
_local1.moveTimer = _local6;
}
_local1.prevUpDown = _local2;
_local1.prevLeftRight = _local3;
_local7++;
}
}
stop();
var allObj = new Array(0);
var nuts = 0;
var maxObj = 100;
var stageWidth = 800;
var stageHeight = 600;
var moveTimerMax = 50;
_root.onEnterFrame = function () {
var _local4 = 0;
while (_local4 < allObj.length) {
var _local2 = allObj[_local4];
if (!_local2.initialTypeSet) {
randomlyChooseType(_local2);
_local2.initialTypeSet = true;
var _local3 = 20;
while (checkCollision(_local2, allObj) != undefined) {
_local2._x = Math.random() * stageWidth;
_local2._y = Math.random() * stageHeight;
if (_local3 == 0) {
break;
}
_local3--;
}
}
var _local5 = checkCollision(_local2, allObj);
if (_local5 != undefined) {
_local2.collidedWith(_local5.getType());
}
_local4++;
}
if (allObj.length < maxObj) {
var _local6 = this.attachMovie("RPS_obj", "deez" + nuts, this.getNextHighestDepth());
_local6._x = 100 + nuts;
_local6._y = 100 + nuts;
allObj.push(_local6);
nuts = nuts + 1;
}
moveObjects(allObj);
showWinningBanner();
};
Symbol 16 MovieClip Frame 1
stop();
Symbol 16 MovieClip Frame 2
stop();
Symbol 16 MovieClip Frame 3
stop();
Symbol 16 MovieClip Frame 4
stop();
Symbol 17 MovieClip [WinnerBanner] Frame 1
function setObj(winningObjName) {
switch (winningObjName) {
case "Rock" :
winningObj.gotoAndStop(2);
break;
case "Paper" :
winningObj.gotoAndStop(3);
break;
case "Scissors" :
winningObj.gotoAndStop(4);
}
winningObj._visible = true;
}
var winningObj = this.winObj;
winningObj._visible = false;
Symbol 18 MovieClip [RPS_obj] Frame 1
function getType() {
var _local2 = this.inner._currentframe;
switch (_local2) {
case 2 :
return("Rock");
case 3 :
return("Paper");
case 4 :
return("Scissors");
}
return("None");
}
function setType(objType) {
var _local2 = this.inner;
switch (objType) {
case "Rock" :
_local2.gotoAndStop(2);
break;
case "Paper" :
_local2.gotoAndStop(3);
break;
case "Scissors" :
_local2.gotoAndStop(4);
break;
default :
_local2.gotoAndStop(1);
}
}
function collidedWith(objType) {
var _local1 = getType();
switch (objType) {
case "Rock" :
if (_local1 != "Paper") {
setType("Rock");
}
break;
case "Paper" :
if (_local1 != "Scissors") {
setType("Paper");
}
break;
case "Scissors" :
if (_local1 == "Rock") {
break;
}
setType("Scissors");
}
}
var moveTimer = 0;
var prevLeftRight;
var prevUpDown;
var initialTypeSet = false;