[問題] 使用迴圈
最近在寫一個判斷陣列長度 去製作影片TWEEN效果的動畫
想要把以下的動作減化
function mb_next1(E:MouseEvent) {
TweenMax.to(mb1_mc, 0.8, {x:-1440, y:0, ease:Back.easeOut});
TweenMax.to(mb2_mc, 0.6, {x:0, y:0, ease:Back.easeOut});
}
mb1_mc.addEventListener(MouseEvent.CLICK,mb_next1);
function mb_next2(E:MouseEvent) {
TweenMax.to(mb2_mc, 0.8, {x:-1440, y:0, ease:Back.easeOut});
TweenMax.to(mb3_mc, 0.6, {x:0, y:0, ease:Back.easeOut});
}
mb2_mc.addEventListener(MouseEvent.CLICK,mb_next2);
減化如下
for (var j:int=1;j<clip.length;j++){
^陣列名稱
function mb_next[j](E:MouseEvent) {
TweenMax.to(this["mb"+j+"_mc"], 0.8, {x:-1440, ease:Back.easeOut});
TweenMax.to(this["mb"+(j+1)+"_mc"], 0.6, {x:0, ease:Back.easeOut});
}
this["mb"+j+"_mc"].addEventListener(MouseEvent.CLICK,mb_next[j]);
可是卻沒辦法執行
想請大家幫忙看看哪邊有出錯了? 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.130.130
※ 編輯: deathhell 來自: 219.87.130.130 (03/08 14:12)
→
03/08 14:18, , 1F
03/08 14:18, 1F
→
03/08 14:20, , 2F
03/08 14:20, 2F
→
03/08 14:21, , 3F
03/08 14:21, 3F
推
03/08 14:38, , 4F
03/08 14:38, 4F
→
03/08 14:39, , 5F
03/08 14:39, 5F
推
03/08 14:40, , 6F
03/08 14:40, 6F
→
03/08 14:40, , 7F
03/08 14:40, 7F
討論串 (同標題文章)