Drag and crash applications, flash learning

Source: Internet
Author: User
Tags array continue eval

Click here to download the source file


Picx_array = new Array (); x coordinate of picture symbol
Picy_array = new Array (); The y-coordinate of the picture symbol
Xx_array = new Array (30, 135, 30, 135, 30, 135); Where the picture is placed in the answer box x coordinates
Yy_array = new Array (110, 110, 170, 170, 230, 230); The picture is placed in the location y-coordinate of the answer box
Ansxx_array=new Array (30,265,370,265,135,30); Picture position x coordinates when the answer is displayed
Ansyy_array=new Array (110,110,110,170,110,170);
M1_array = new Array (0, 0, 0, 0, 0, 0); First answer box put picture position flag
M2_array = new Array (0, 0, 0, 0, 0, 0); The second answer box puts the picture position flag
Answer_array = new Array (0, 0, 0, 0, 0, 0); An array of answer records
Key_array = new Array (1, 2, 2, 2, 1, 1); Correct answer, 1 means picture in first answer box
Pic_num = 6; Total pictures
Answer._visible = false; Results display panel hidden
Answer.swapdepths (30); Swap to depth 30
for (var i = 1; i<pic_num+1; i++) {
Picx_array[i-1] = eval ("Pic" +i). _x; Store the initial position of a picture in an array
Picy_array[i-1] = eval ("Pic" +i). _y;
Eval ("Pic" +i). Swapdepths (i); and place the depth
Eval ("Pic" +i). PD1 = 0; Position variable
Eval ("Pic" +i). pd2 = 0;
}
for (var i = 1; i<pic_num+1; i++) {
Eval ("Pic" +i). onpress = function () {//Picture receives mouse down information
This.startdrag (); Drag a picture
This.swapdepths (20); Depth to 20
This._alpha = 65; Transparency is 65
M1_array[this.pd1-1] = 0;
M2_ARRAY[THIS.PD2-1] = 0;
};
Eval ("Pic" +i). Onrelease = function () {
This.stopdrag (); Stop dragging
TMP = Number (This._name.slice (3, 4)); Extract numbers from a picture symbol
This.swapdepths (TMP); Exchange for the original depth
This._alpha = 100; Transparency is 100
if (This.hittest (M1_MC)) {//If contact with the answer box
end = 0;
for (var m = 1; m<7; m++) {
if (end = = 0) {
if (m1_array[m-1] = = 0) {
this._x = Xx_array[m-1];
this._y = Yy_array[m-1];
M1_ARRAY[M-1] = 1;
ANSWER_ARRAY[TMP-1] = 1;
Trace (Answer_array);
end = 1;
THIS.PD1 = m;
THIS.PD2 = 0;
PD3 = 0;
Continue
}
this._x = Picx_array[tmp-1];
this._y = Picy_array[tmp-1];
Answer[tmp-1] = 0;
THIS.PD1 = 0;
THIS.PD2 = 0;
PD3 = 0;
}
}
else if (This.hittest (M2_MC)) {
end = 0;
for (var m = 1; m<7; m++) {
if (end = = 0) {
if (m2_array[m-1] = = 0) {
this._x = xx_array[m-1]+240;
this._y = Yy_array[m-1];
M2_ARRAY[M-1] = 1;
ANSWER_ARRAY[TMP-1] = 2;
Trace (Answer_array);
end = 1;
THIS.PD1 = 0;
THIS.PD2 = m;
PD3 = 0;
Continue
}
this._x = Picx_array[tmp-1];
this._y = Picy_array[tmp-1];
Answer[tmp-1] = 0;
THIS.PD1 = 0;
THIS.PD2 = 0;
PD3 = 0;
}
}
} else {
this._x = Picx_array[tmp-1];
this._y = Picy_array[tmp-1];
THIS.PD1 = 0;
THIS.PD2 = 0;
PD3 = 0;
}
};
}
Answer_show.onrelease = function () {
Answer._visible = true;
Key = 0;
for (var i = 0; i<6; i++) {
if (answer_array[i] = = Key_array[i]) {
key++;
}
}
Answer.right_num = key;
};
answer.head.onPress = function () {
Answer.startdrag ();
};
Answer.head.onRelease = function () {
Answer.stopdrag ();
};
Answer.close_win.onRelease = function () {
Answer._visible = false;
};
Answer.answer.onrelease=function () {
for (Var i=1;i<7;i++) {
Eval ("Pic" +i). _x=ansxx_array[i-1];
Eval ("Pic" +i). _y=ansyy_array[i-1];
Eval ("Pic" +i). Onpress=function () {};
Eval ("Pic" +i). Onrelease=function () {};
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.