Flash Number jumbler game

Flash Number Jumbler Game

Step-1 Open a new document in flash. Set the width and height across 300 pixels.

number-jumbler-game
image-473

Step-2 Set the background as you like. Create box like below in layer-1 and convert it into movieclip (f8) then name it as box1. Like that create 20 boxes in separate layers and name it as like box2, box3, ….. , box20. Now you have 20 layers in your document.

number-jumbler-game
image-474

Step-3 Create layer-21 and type 1 on box1 as like below. Remember that your text type should be dynamic and name it as s1 as variable in variable box (see the properties dialog box).

number-jumbler-game
image-475

number-jumbler-game
image-476

Step-4 Likewise creates 20 dynamic texts in 20 different layers and name it as s2, s3, …. , s20. Finally you have 40 layers. Now lock  layer-21 to layer-40.

Step-5 Select box1 and write the following code by press F9 to open the actionscript window:

onClipEvent (enterFrame)

{

this.onPress = function ()

{

var _loc1 = _root;

if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “)

{

if (_loc1.s2 == ” “)

{

_loc1.s2 = _loc1.s1;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s6 == ” “)

{

_loc1.s6 = _loc1.s1;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s7 == ” “)

{

_loc1.s7 = _loc1.s1;

_loc1.box7._alpha = 100;

} // end if

_loc1.s1 = ” “;

this._alpha = 50;

} // end if

};

}

Code Explanation:

In line 6 if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “)

_loc1 is a variable

s2, s6, s7 are represents dynamic text boxes and are adjacent to s1.

Step-6 Repeat step-5 for all boxes. The above code will change for each boxes. The changes you have make on variables and movieclip names according to adjacent boxes..

For example code for box12 will change as like follows (changes are highlighted):

onClipEvent (enterFrame)

{

this.onPress = function ()

{

var _loc1 = _root;

if (_loc1.s7 == ” ” || _loc1.s11 == ” ” || _loc1.s13 == ” ” || _loc1.s17 == ” “)

{

if (_loc1.s7 == ” “)

{

_loc1.s7 = _loc1.s12;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s11 == ” “)

{

_loc1.s11 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s13 == ” “)

{

_loc1.s13 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “)

{

_loc1.s17 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box17._alpha = 100;

} // end if

_loc1.s12 = ” “;

this._alpha = 50;

} // end if

};

}

Note: Box 7 (6, 2, 8, 12), 8 (3, 7, 9, 13), 9(4, 8, 10, 14), 12 (7, 11, 13, 17), 13 (8, 12, 14, 18), 14(9, 13, 15, 19) will have four adjacent boxes

Step-8: Create layer-41 and type Collapse. Convert it into movieclip(F8) and name it as randomize (to change the numbers randomly). Write the following code on randomize movieclip by press F9 to open the actionscript window

number-jumbler-game
image-477

onClipEvent (load) {

_root.box20._alpha = 50;

_root.s1 = 12;

_root.s2 = 3;

_root.s3 = 9;

_root.s4 = 16;

_root.s5 = 1;

_root.s6 = 2;

_root.s7 = 8;

_root.s8 = 10;

_root.s9 = 11;

_root.s10 = 15;

_root.s11 = 4;

_root.s12 = 17;

_root.s13 = 13;

_root.s14 = 5;

_root.s15 = 14;

_root.s16 = 16;

_root.s17 = 6;

_root.s18 = 18;

_root.s19 = 7;

_root.s20 = ” “;

}

onClipEvent (load) {

getURL(“FSCommand:allowscale”, 0);

getURL(“FSCommand:showmenu”, 0);

getURL(“FSCommand:fullscreen”, 0);

}

onClipEvent (enterFrame) {

_root.randomize.onPress = function() {

var _loc1 = _root;

var _loc2 = this;

for (i=0; i<500; i++) {

s = random(20)+1;

switch (s) {

case 1 :

if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s1;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s1;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s1;

_loc1.box7._alpha = 100;

} // end if

_loc1.s1 = ” “;

this._alpha = 50;

} // end if

break;

case 2 :

if (_loc1.s1 == ” ” || _loc1.s3 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s1 == ” “) {

_loc1.s1 = _loc1.s2;

_loc1.box1._alpha = 100;

} // end if

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s2;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s2;

_loc1.box7._alpha = 100;

} // end if

_loc1.s2 = ” “;

this._alpha = 50;

} // end if

break;

case 3 :

if (_loc1.s2 == ” ” || _loc1.s8 == ” ” || _loc1.s4 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s3;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s3;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s3;

_loc1.box4._alpha = 100;

} // end if

_loc1.s3 = ” “;

this._alpha = 50;

} // end if

break;

case 4 :

if (_loc1.s3 == ” ” || _loc1.s9 == ” ” || _loc1.s5 == ” “) {

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s4;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s4;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s5 == ” “) {

_loc1.s5 = _loc1.s4;

_loc1.box5._alpha = 100;

} // end if

_loc1.s4 = ” “;

this._alpha = 50;

} // end if

break;

case 5 :

if (_loc1.s4 == ” ” || _loc1.s9 == ” ” || _loc1.s10 == ” “) {

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s5;

_loc1.box4._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s5;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s5;

_loc1.box10._alpha = 100;

} // end if

_loc1.s5 = ” “;

this._alpha = 50;

} // end if

break;

case 6 :

if (_loc1.s1 == ” ” || _loc1.s11 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s1 == ” “) {

_loc1.s1 = _loc1.s6;

_loc1.box1._alpha = 100;

} // end if

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s6;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s6;

_loc1.box7._alpha = 100;

} // end if

_loc1.s6 = ” “;

this._alpha = 50;

} // end if

break;

case 7 :

if (_loc1.s2 == ” ” || _loc1.s12 == ” ” || _loc1.s6 == ” ” || _loc1.s8 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s7;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s7;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s7;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s7;

_loc1.box8._alpha = 100;

} // end if

_loc1.s7 = ” “;

this._alpha = 50;

} // end if

break;

case 8 :

if (_loc1.s3 == ” ” || _loc1.s7 == ” ” || _loc1.s9 == ” ” || _loc1.s13 == ” “) {

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s8;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s8;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s8;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s8;

_loc1.box13._alpha = 100;

} // end if

_loc1.s8 = ” “;

this._alpha = 50;

} // end if

break;

case 9 :

if (_loc1.s4 == ” ” || _loc1.s8 == ” ” || _loc1.s10 == ” ” || _loc1.s14 == ” “) {

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s9;

_loc1.box4._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s9;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s9;

_loc1.box10._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s9;

_loc1.box14._alpha = 100;

} // end if

_loc1.s9 = ” “;

this._alpha = 50;

} // end if

break;

case 10 :

if (_loc1.s15 == ” ” || _loc1.s9 == ” ” || _loc1.s5 == ” “) {

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s10;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s10;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s5 == ” “) {

_loc1.s5 = _loc1.s10;

_loc1.box5._alpha = 100;

} // end if

_loc1.s10 = ” “;

this._alpha = 50;

} // end if

break;

case 11 :

if (_loc1.s6 == ” ” || _loc1.s12 == ” ” || _loc1.s16 == ” “) {

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s11;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s11;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s16 == ” “) {

_loc1.s16 = _loc1.s11;

_loc1.box16._alpha = 100;

} // end if

_loc1.s11 = ” “;

this._alpha = 50;

} // end if

break;

case 12 :

if (_loc1.s7 == ” ” || _loc1.s11 == ” ” || _loc1.s13 == ” ” || _loc1.s17 == ” “) {

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s12;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s12;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s12;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s12;

_loc1.box17._alpha = 100;

} // end if

_loc1.s12 = ” “;

this._alpha = 50;

} // end if

break;

case 13 :

if (_loc1.s14 == ” ” || _loc1.s12 == ” ” || _loc1.s8 == ” ” || _loc1.s18 == ” “) {

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s13;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s13;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8= _loc1.s13;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s13;

_loc1.box18._alpha = 100;

} // end if

_loc1.s13 = ” “;

this._alpha = 50;

break;

case 14 :

if (_loc1.s9 == ” ” || _loc1.s13 == ” ” || _loc1.s15 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s14;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s14;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s14;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s14;

_loc1.box19._alpha = 100;

} // end if

_loc1.s14 = ” “;

this._alpha = 50;

} // end if

break;

case 15 :

if (_loc1.s10 == ” ” || _loc1.s14 == ” ” || _loc1.s20 == ” “) {

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s15;

_loc1.box10._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s15;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s20 == ” “) {

_loc1.s20 = _loc1.s15;

_loc1.box20._alpha = 100;

} // end if

_loc1.s15 = ” “;

this._alpha = 50;

} // end if

break;

case 16 :

if (_loc1.s11 == ” ” || _loc1.s12 == ” ” || _loc1.s17 == ” “) {

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s16;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s16;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s16;

_loc1.box17._alpha = 100;

} // end if

_loc1.s16 = ” “;

this._alpha = 50;

} // end if

break;

case 17 :

if (_loc1.s12 == ” ” || _loc1.s16 == ” ” || _loc1.s18 == ” “) {

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s17;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s16 == ” “) {

_loc1.s16 = _loc1.s17;

_loc1.box16._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s17;

_loc1.box18._alpha = 100;

} // end if

_loc1.s17 = ” “;

this._alpha = 50;

} // end if

break;

case 18 :

if (_loc1.s13 == ” ” || _loc1.s17 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s18;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s18;

_loc1.box17._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s18;

_loc1.box19._alpha = 100;

} // end if

_loc1.s18 = ” “;

this._alpha = 50;

} // end if

break;

case 19:

if (_loc1.s14 == ” ” || _loc1.s18 == ” ” || _loc1.s20 == ” “) {

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s19;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s19;

_loc1.box18._alpha = 100;

} // end if

if (_loc1.s20 == ” “) {

_loc1.s20 = _loc1.s19;

_loc1.box20._alpha = 100;

} // end if

_loc1.s19 = ” “;

this._alpha = 50;

} // end if

break;

case 20 :

if (_loc1.s15 == ” ” || _loc1.s14 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s20;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s20;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s20;

_loc1.box19._alpha = 100;

} // end if

_loc1.s20 = ” “;

this._alpha = 50;

} // end if

break;

}

// End of switch

}

// end of for

};

};

}

Now run the program.

Click to download the source file Number jumbler

Tags: , , ,

Request a Free SEO Quote