Flash as 中关于MC的控制问题
整理的关于MC的控制。同时有几个MC,通过点击不同的MC,调用同一个函数,根据点击MC 的不同产生不同的结果(比如一层有5个:MCa1、MCa2.......MCa5,另外一层上有个MCb,MCb里面有连续5帧,每帧都有一张图片,我通过点击MCa1显示第一张图片,点击MCa2显示第二张图片。。。。。。)
var dict = new Dictionary();
for (var i=0; i<6; i++) {
//DisplayObjectContainer
var a_mc:MovieClip =getChildAt(i) as MovieClip;
dict[a_mc] = i;
}
dict[(event.currentTarget as MovieClip)];
这个方法有点笨,当MC很多的时候,代码就显得很冗余:
a0_mc.addEventListener(MouseEvent.CLICK,a0);
function a0(event:MouseEvent) {
a0_mc.buttonMode=true;
b_mc.gotoAndStop(2);
}
a1_mc.addEventListener(MouseEvent.CLICK,a1);
function a1(event:MouseEvent) {
a1_mc.buttonMode=true;
b_mc.gotoAndStop(3);
}
a2_mc.addEventListener(MouseEvent.CLICK,a2);
function a2(event:MouseEvent) {
a2_mc.buttonMode=true;
b_mc.gotoAndStop(4);
}
a3_mc.addEventListener(MouseEvent.CLICK,a3);
function a3(event:MouseEvent) {
a3_mc.buttonMode=true;
b_mc.gotoAndStop(5);
}
a4_mc.addEventListener(MouseEvent.CLICK,a4);
function a4(event:MouseEvent) {
a4_mc.buttonMode=true;
b_mc.gotoAndStop(6);
}
a5_mc.addEventListener(MouseEvent.CLICK,a5);
function a5(event:MouseEvent) {
a5_mc.buttonMode=true;
b_mc.gotoAndStop(7);
}
谁有更好的方法,可以分享哈!
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |