作者hirabbitt (兔子)
看板Flash
標題[問題] 用for做function
時間Mon Dec 12 00:26:30 2011
for(i=0;i<5;i++){
questImage=new canGet();
questImage.addEventListener(MouseEvent.CLICK,function(e:MouseEvent):void{
var tempi:int=i;
trace(i+" "+tempi); //實際在按的時候i和tempi印出來都是1 但我想要0~4
});
}
我有想過把i傳值傳進去
但是不知道MouseEvent.CLICK的function是否可以直接function(e:MouseEvent,temp:int)
感謝
--
◤ __ \__◣
◢◤◢◤ ψhirabbitt
◢ ◤ ◢███◣
◢███◣
我摸不到妳 █████
█████ 妳摸不到我
██
●█
● █▇███
██
╱╲ ●◥█████◣●
◥
╱█
╱╱ ● ◥████
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.228.252.92
※ 編輯: hirabbitt 來自: 125.228.252.92 (12/12 00:26)
推 cjcat2266:精華區 3>7>3>1 12/12 04:16
→ hirabbitt:對不起我沒有仔細看精華區>_< 12/12 08:53
→ hirabbitt:所以說Dictionary就是不限定[]裡面只能放數字或字串的 12/12 08:53
→ hirabbitt:Array嘍 12/12 08:53
推 chengchieh:dict的index跟value都沒有限制型別 12/12 09:20
→ chengchieh:你的canGet是自訂的class...也可以考慮增加一個index 12/12 09:21
→ chengchieh:的變數吧...有需要常用到的話 12/12 09:21