orange gold
12-29-2008, 08:27 AM
on frame 2 replace your code with this code...
import fl.transitions.Tween;
import fl.transitions.easing.*;
stop();
var level1: Array = [
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1]
];
var level2: Array = [
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2],
[11,11,11,11,11,11,11,11,11,11],
[11,11,11,11,11,11,11,11,11,11],
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2],
[2,2,2,2,11,11,2,2,2,2]
];
var level3: Array = [
[3,3,3,3,3,3,3,3,3,3],
[0,0,0,0,0,0,0,0,0,3],
[0,3,3,3,3,3,3,3,0,3],
[0,3,0,0,0,0,0,3,0,3],
[0,3,0,3,3,3,0,3,0,3],
[0,3,0,3,0,3,0,3,0,3],
[0,3,0,3,0,0,0,3,0,3],
[0,3,0,3,3,3,3,3,0,3],
[0,3,0,0,0,0,0,0,0,3],
[0,3,3,3,3,3,3,3,3,3]
];
var level4: Array = [
[4,5,6,0,6,6,0,6,5,4],
[5,6,0,0,6,6,0,0,6,5],
[6,0,0,0,5,5,0,0,0,6],
[0,0,0,0,5,5,0,0,0,0],
[6,6,5,5,4,4,5,5,6,6],
[6,6,5,5,4,4,5,5,6,6],
[0,0,0,0,5,5,0,0,0,0],
[6,0,0,0,5,5,0,0,0,6],
[5,6,0,0,6,6,0,0,6,5],
[4,5,6,0,6,6,0,6,5,4]
];
var level5: Array = [
[8,8,8,8,8,8,8,8,8,8],
[0,8,9,9,9,9,9,9,8,0],
[0,0,8,9,9,9,9,8,0,0],
[0,0,0,8,9,9,8,0,0,0],
[0,0,0,0,8,8,0,0,0,0],
[0,0,0,0,8,8,0,0,0,0],
[0,0,0,8,9,9,8,0,0,0],
[0,0,8,9,9,9,9,8,0,0],
[0,8,9,9,9,9,9,9,8,0],
[8,8,8,8,8,8,8,8,8,8]
];
var level6: Array = [
[0,0,7,7,7,7,7,7,0,0],
[0,7,7,7,7,7,7,7,7,0],
[7,7,9,7,7,7,7,9,7,7],
[7,8,9,9,7,7,8,9,9,7],
[7,7,9,7,7,7,7,9,7,7],
[7,7,7,7,7,7,7,7,7,7],
[7,7,7,7,7,7,7,7,7,7],
[7,7,7,7,7,7,7,7,7,7],
[7,7,7,7,7,7,7,7,7,7],
[7,7,0,0,7,7,0,0,7,7]
];
var level7: Array = [
[0,0,0,0,0,0,0,10,0,0],
[0,0,0,0,0,0,10,10,0,0],
[0,0,00,0,0,10,0,10,0,0],
[0,0,10,0,0,0,0,10,0,0],
[0,0,10,0,0,0,0,10,0,0],
[10,10,10,10,10,0,0,10,0,0],
[0,0,10,0,0,0,0,10,0,0],
[0,0,10,0,0,0,0,10,0,0],
[0,0,0,0,0,0,0,10,0,0],
[0,0,0,0,0,10,10,10,10,10]
];
var level8: Array = [
[1,1,1,1,1,1,1,1,1,1],
[0,2,0,0,0,0,0,0,2,0],
[0,2,3,3,3,3,3,3,2,0],
[0,2,0,4,0,0,4,0,2,0],
[0,2,0,4,0,5,4,0,2,0],
[0,2,0,4,5,0,4,0,2,0],
[0,2,0,4,0,0,4,0,2,0],
[0,2,3,3,3,3,3,3,2,0],
[0,2,0,0,0,0,0,0,2,0],
[1,1,1,1,1,1,1,1,1,1]
];
var level9: Array = [
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0]
];
var level10: Array = [
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)],
[Math.ceil(Math.random()*14),Math.ceil(Math.random( )*14),Math.ceil(Math.random()*14),Math.ceil(Math.r andom()*14),Math.ceil(Math.random()*14),Math.ceil( Math.random()*14),Math.ceil(Math.random()*14),Math .ceil(Math.random()*14),Math.ceil(Math.random()*14 ),Math.ceil(Math.random()*14)]
];
var upComing: int = 1;
var spheres: Array = new Array();
var i: int;
var target: int;
var health: int;
var score: int;
var itemsTotal: int;
var percentage: int;
var itemsSelected:int;
var selectionSprite:Sprite;
var startX:Number;
var startY:Number;
var myTimer:Timer = new Timer(10000, 0);
var timer:int;
var tween1:Tween;
/*--------------------------------------------------------
--------------------------------------------------------*/
level(level1);
init();
function level (currentlevel){
for(var i:int = 0; i < 10; i++){
for(var j:int = 0; j < 10; j++){
if(currentlevel[i][j]==1){
var blue:blueSphere = new blueSphere();
blue.x = 25 +j*35;
blue.y = 30 + i*35;
addChild(blue);
spheres.push(blue);
}
else if (currentlevel[i][j] ==2){
var red:redSphere = new redSphere()
red.x = 25 +j*35;
red.y = 30 + i*35;
addChild(red);
spheres.push(red);
}
else if (currentlevel[i][j] ==3){
var green:greenSphere = new greenSphere();
green.x = 25 +j*35;
green.y = 30 + i*35;
addChild(green);
spheres.push(green);
}
else if (currentlevel[i][j] ==4){
var orange:orangeSphere = new orangeSphere();
orange.x = 25 +j*35;
orange.y = 30 + i*35;
addChild(orange);
spheres.push(orange);
}
else if (currentlevel[i][j] ==5){
var yellow:yellowSphere = new yellowSphere();
yellow.x = 25 +j*35;
yellow.y = 30 + i*35;
addChild(yellow);
spheres.push(yellow);
}
else if (currentlevel[i][j] ==6){
var brown:brownSphere = new brownSphere();
brown.x = 25 +j*35;
brown.y = 30 + i*35;
addChild(brown);
spheres.push(brown);
}
else if (currentlevel[i][j] ==7){
var purple:purpleSphere = new purpleSphere();
purple.x = 25 +j*35;
purple.y = 30 + i*35;
addChild(purple);
spheres.push(purple);
}
else if (currentlevel[i][j] ==8){
var black:blackSphere = new blackSphere();
black.x = 25 +j*35;
black.y = 30 + i*35;
addChild(black);
spheres.push(black);
}
else if (currentlevel[i][j] ==9){
var white:whiteSphere = new whiteSphere();
white.x = 25 +j*35;
white.y = 30 + i*35;
addChild(white);
spheres.push(white);
}
else if (currentlevel[i][j] ==10){
var multi:multiSphere = new multiSphere();
multi.x = 25 +j*35;
multi.y = 30 + i*35;
addChild(multi);
spheres.push(multi);
}
}
}
for(i = 0; i < spheres.length; i++) {
spheres[i].glow=false;
}
itemsTotal = 0;
for(i = 0; i < spheres.length; i++) {
if(spheres[i].alpha ==1){
itemsTotal++;
}
}
target = 100*Math.ceil((Math.random()*itemsTotal))/itemsTotal;
percentage_txt.text = String(target) + "%";
items_txt.text = String(itemsSelected + "/" + itemsTotal);
for(i = 0; i < spheres.length; i++) {
spheres[i].addEventListener(MouseEvent.CLICK,select);
}
}
function init(){
target = Math.round(Math.random()*100+1);
health = 100;
score = 0;
percentage = 0;
itemsSelected = 0;
selectionSprite = new Sprite();
addChild(selectionSprite);
timer = 5;
stage.addEventListener(MouseEvent.MOUSE_DOWN, down);
stage.addEventListener(MouseEvent.MOUSE_UP, up);
stage.addEventListener(KeyboardEvent.KEY_DOWN, kaPow);
myTimer.addEventListener(TimerEvent.TIMER, countDown);
myTimer.start();
gameOver_txt.text = "";
endScore_txt.text = "";
playAgain_txt.text = ""
playAgain_mc.removeEventListener(MouseEvent.CLICK, again);
//fill in text box.
score_txt.text=String(score);
percentage_txt.text = String(target);
health_txt.text=String(health);
timer_txt.text = String(timer);
}
function countDown(event:TimerEvent):void {
timer -=1;
timer_txt.text = String(timer);
if(timer==0){
endGame();
}
}
continued in the next post.... too long of code for this post
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.