·您的位置: 首页 » 资源教程 » 创意设计 » Flash » 拖动与碰撞的应用,Flash学习

拖动与碰撞的应用,Flash学习

类别: Flash教程  评论数:0 总得分:0

« Full Screen »

点击这里下载源文件


picx_array = new Array(); //图片元件的X坐标
picy_array = new Array(); //图片元件的Y坐标
xx_array = new Array(30, 135, 30, 135, 30, 135); //图片被放入答案框的位置 X坐标
yy_array = new Array(110, 110, 170, 170, 230, 230); // 图片被放入答案框的位置 Y坐标
ansxx_array=new Array(30,265,370,265,135,30); //显示答案时的图片位置x坐标
ansyy_array=new Array(110,110,110,170,110,170);
m1_array = new Array(0, 0, 0, 0, 0, 0); //第一个答案框放入图片位置标志
m2_array = new Array(0, 0, 0, 0, 0, 0); //第二个答案框放入图片位置标志
answer_array = new Array(0, 0, 0, 0, 0, 0); //答案记录数组
key_array = new Array(1, 2, 2, 2, 1, 1); //正确答案,1表示图片在第一个答案框
pic_num = 6; //图片总数
answer._visible = false; //结果显示板隐藏
answer.swapDepths(30); //交换到深度30
for (var i = 1; i<pic_num+1; i++) {
picx_array[i-1] = eval("pic"+i)._x; //将图片的初始位置存入数组
picy_array[i-1] = eval("pic"+i)._y;
eval("pic"+i).swapDepths(i); //并置入深度
eval("pic"+i).pd1 = 0; //位置变量
eval("pic"+i).pd2 = 0;
}
for (var i = 1; i<pic_num+1; i++) {
eval("pic"+i).onPress = function() {//图片接收鼠标按下信息
this.startDrag(); //将图片拖动
this.swapDepths(20); //深度置为20
this._alpha = 65; //透明度为65
m1_array[this.pd1-1] = 0;
m2_array[this.pd2-1] = 0;
};
eval("pic"+i).onRelease = function() {
this.stopDrag(); //停止拖动
tmp = Number(this._name.slice(3, 4)); //提取图片元件中的数字
this.swapDepths(tmp); //交换为原来的深度
this._alpha = 100; //透明度为100
if (this.hitTest(m1_mc)) { //如果与答案框一接触
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(){ };
}

}
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1