快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

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

« 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(){ };
}

}

返回类别: Flash教程
上一教程: 巧妙运用Flash MX 2004制作“拖曳配对题”
下一教程: 用MP3或WAV制作人声铃声的简朴教程

您可以阅读与"拖动与碰撞的应用,Flash学习"相关的教程:
· FLASH结合ASP数据库的应用
· Flash视频教程实例:任意变形工具的应用
· flash 8 BitmapData 类的应用
· Flash AS学习:mx.utils包之Delegate类应用
· Flash 8中swf metadate的应用问答
    微笑服务 优质保证 索取样品