Friday 13 February 2015

MATCHING PAIR GAME AS3

MATCHING PAIR GAME AS3




______________________________________________________________________________

COPY AND PASTE BELOW CODE
READ MORE:
http://www.algoonline.net/AdobeFlash-MemoryGame/Flash_Game_Matching_Pair.htm
http://labs.jasonsturges.com/stack-overflow/examples/box-match/

Index of /stack-overflow/examples/box-match/


../
box-match.fla                                      29-Nov-2013 06:36                9306
box-match.html                                     29-Nov-2013 06:36                2036
box-match.swf                                      29-Nov-2013 06:36                1936


DOWNLOAD SOURCE FILE:
http://bit.ly/1FKzHS3
______________________________________________________________________________


myMC.buttonMode=true;
myMC.addEventListener(MouseEvent.CLICK, fl_onClick);
myMC.addEventListener(MouseEvent.MOUSE_OUT, fl_onMouseOut);

var visited=false;
var mask_opened = 0;
var icons_array:Array = new Array(Icon1, Icon2, Icon3, Icon4, Icon5, Icon6, Icon7, Icon8, Icon9);
var icons_location_x:Array = new Array(110, 270, 420, 110, 270, 420, 110, 270, 420);
var icons_location_y:Array = new Array(40, 40, 40, 170, 170, 170, 300, 300, 300);
var pair_icons:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0);
var temp_Array:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9);
var mouse_click_icon:Array = new Array(0, 0);
var Masks:Array = new Array(Mask_1, Mask_2, Mask_3, Mask_4, Mask_5, Mask_6, Mask_7, Mask_8, Mask_9);
var temp1 = 0, temp2 = 0;

startup();

function startup() {
 for(temp1 = 0; temp1 < 9; temp1++) {
  temp2 = Math.floor(Math.random() * (9 - temp1) );
  pair_icons[temp1] = temp_Array[temp2];
  while(temp2 < 8 && temp_Array[temp2] != 0) {
   temp_Array[temp2] = temp_Array[temp2 + 1];
   ++temp2;
  }
  temp_Array[temp2] = 0;
  
  trace(pair_icons[temp1]);


  icons_array[pair_icons[temp1] - 1].x = icons_location_x[temp1];
  icons_array[pair_icons[temp1] - 1].y = icons_location_y[temp1];
 }
}

function fl_onClick(evt:MouseEvent):void {
 //your code here
 trace("Button clicked");
 //clicked, so page has been visited
 visited=true;
}

function fl_onMouseOut(evt:MouseEvent):void {
 if (visited) {
  myMC.gotoAndStop("visited");
 }
}

function check_Pic_Tally()
{
 var temp3 = mouse_click_icon[0];
 var temp4 = mouse_click_icon[1];

 mouse_click_icon[0] = pair_icons[mouse_click_icon[0] - 1];
 mouse_click_icon[1] = pair_icons[mouse_click_icon[1] - 1];

 if(mouse_click_icon[0] > mouse_click_icon[1]) {
  temp1 = mouse_click_icon[0];
  mouse_click_icon[0] = mouse_click_icon[1];
  mouse_click_icon[1] = temp1;
 }
 trace(mouse_click_icon[0] + " " + mouse_click_icon[1]);

 if ( ( (mouse_click_icon[0] == 1) && (mouse_click_icon[1] == 2) ) || 
   ( (mouse_click_icon[0] == 3) && (mouse_click_icon[1] == 4) ) ||
   ( (mouse_click_icon[0] == 5) && (mouse_click_icon[1] == 6) ) ||
   ( (mouse_click_icon[0] == 7) && (mouse_click_icon[1] == 8) ) ) {
    
   }
 else {
  Masks[temp3 - 1].visible = true;
  Masks[temp4 - 1].visible = true;
 }
 mouse_click_icon[0] = 0;
 mouse_click_icon[1] = 0;
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");

 Mask_1.visible = false;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  mask_opened = mask_opened + 1;
  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 1;
  else
   mouse_click_icon[1] = 1;
 }

 // End your custom code
}
/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);

function fl_MouseClickHandler_2(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");


 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_2.visible = false; 
  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 2;
  else
   mouse_click_icon[1] = 2;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_3.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);

function fl_MouseClickHandler_3(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");


 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_3.visible = false;
  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 3;
  else
   mouse_click_icon[1] = 3;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_4.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);

function fl_MouseClickHandler_4(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");


 mask_opened = mask_opened + 1;
  
 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_4.visible = false;
  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 4;
  else
   mouse_click_icon[1] = 4;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_5.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_5);

function fl_MouseClickHandler_5(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");


 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_5.visible = false;
  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 5;
  else
   mouse_click_icon[1] = 5;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_6.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_6);

function fl_MouseClickHandler_6(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");

 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_6.visible = false;

  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 6;
  else
   mouse_click_icon[1] = 6;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_7.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_7);

function fl_MouseClickHandler_7(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");


 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_7.visible = false;

  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 7;
  else
   mouse_click_icon[1] = 7;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_8.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_8);

function fl_MouseClickHandler_8(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");

 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_8.visible = false;

  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 8;
  else
   mouse_click_icon[1] = 8;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

Mask_9.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_9);

function fl_MouseClickHandler_9(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");

 mask_opened = mask_opened + 1;

 if (mask_opened >= 3) {
  check_Pic_Tally();
  mask_opened = 0;
 }
 else {
  Mask_9.visible = false;

  if (mouse_click_icon[0] == 0)
   mouse_click_icon[0] = 9;
  else
   mouse_click_icon[1] = 9;
 }
 // End your custom code
}

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

myMC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_10);

function fl_MouseClickHandler_10(event:MouseEvent):void
{
 // Start your custom code
 // This example code displays the words "Mouse clicked" in the Output panel.
 trace("Mouse clicked");
 mask_opened = 0;
 mouse_click_icon[0] = 0;
 mouse_click_icon[1] = 0;

 temp_Array[0] = 1;
 temp_Array[1] = 2;
 temp_Array[2] = 3;
 temp_Array[3] = 4;
 temp_Array[4] = 5;
 temp_Array[5] = 6;
 temp_Array[6] = 7;
 temp_Array[7] = 8;
 temp_Array[8] = 9;
  
 Mask_1.visible = true;
 Mask_2.visible = true;
 Mask_3.visible = true;
 Mask_4.visible = true;
 Mask_5.visible = true;
 Mask_6.visible = true;
 Mask_7.visible = true;
 Mask_8.visible = true;
 Mask_9.visible = true;

 startup();
 // End your custom code
}


----------------------------------------------------------------------------------------------------------------
IN THIS CODE HOW ICON MOVIE CHANGE POSITION
MOVIE XY LOCATION MENTION IN THIS CODE
-----------------------------------------------------------------------------------------------------------------




var icons_array:Array = new Array(Icon1, Icon2, Icon3, Icon4, Icon5, Icon6, Icon7, Icon8, Icon9);
var icons_location_x:Array = new Array(110, 270, 420, 110, 270, 420, 110, 270, 420);
var icons_location_y:Array = new Array(40, 40, 40, 170, 170, 170, 300, 300, 300);
var pair_icons:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0);
var temp_Array:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9);
var mouse_click_icon:Array = new Array(0, 0);

var temp1 = 0, temp2 = 0;


startup();
function startup() {
for(temp1 = 0; temp1 < 9; temp1++) {
temp2 = Math.floor(Math.random() * (9 - temp1) );
pair_icons[temp1] = temp_Array[temp2];
while(temp2 < 8 && temp_Array[temp2] != 0) {
temp_Array[temp2] = temp_Array[temp2 + 1];
++temp2;
}
temp_Array[temp2] = 0;
trace(pair_icons[temp1]);
icons_array[pair_icons[temp1] - 1].x = icons_location_x[temp1];
icons_array[pair_icons[temp1] - 1].y = icons_location_y[temp1];
}
}

-------------------------------------------------------------------------------------------------------------------
MAKE MOVIE SHUFFLE ARRAY WITH 3 ICONS  USE THIS CODE
DOWNLOAD SOUR CE FILE:
-------------------------------------------------------------------------------------------------------------------

var icons_array:Array = new Array(Icon1, Icon2, Icon3);
var icons_location_x:Array = new Array(110, 270, 420);
var icons_location_y:Array = new Array(40, 40, 40);
var pair_icons:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0);
var temp_Array:Array = new Array(1, 2, 3);

var temp1 = 0, temp2 = 0;


startup();
function startup() {
for(temp1 = 0; temp1 < 3; temp1++) {
temp2 = Math.floor(Math.random() * (3 - temp1) );
pair_icons[temp1] = temp_Array[temp2];
while(temp2 < 2 && temp_Array[temp2] != 0) {
temp_Array[temp2] = temp_Array[temp2 + 1];
++temp2;
}
temp_Array[temp2] = 0;
trace(pair_icons[temp1]);
icons_array[pair_icons[temp1] - 1].x = icons_location_x[temp1];
icons_array[pair_icons[temp1] - 1].y = icons_location_y[temp1];
}
}










EmoticonEmoticon