作者sledogerunir (隐密忍者农丸)
看板Flash
标题Re: [问题] 关於AS3.0 侦听事件的函数参数第2问
时间Tue Mar 9 16:07:22 2010
t1_btn.addEventListener(MouseEvent.CLICK, getSetup);
t2_btn.addEventListener(MouseEvent.CLICK, getSetup);
function getSetup(event:MouseEvent):void
{
switch(event.currentTarget as SimpleButton)
{
case t1_btn:
set.text=String(35);
break;
case t2_btn:
set.text=String(70);
break;
}
}
上一篇的版众大已经回答的差不多了~用event判断
※ 引述《godsing (执着是苦)》之铭言:
: 虽然之前问过了,不过还是弄不出来,没碰上实际例子,也不知道要怎麽继续问
: 小弟太资潜了....
: 这次是实际碰上的问题,其实是把之前的AS2.0作品要改成3.0所碰上的问题
: t1_btn.addEventListener(MouseEvent.CLICK, getSetup1);
: t2_btn.addEventListener(MouseEvent.CLICK, getSetup2);
: function getSetup1(event:MouseEvent):void {
: set.text=String(35);
: }
: function getSetup2(event:MouseEvent):void {
: set.text=String(70);
: }
: 实际按钮有很多,这里取2个
: 请问我有什麽办法可以把它简化成
: t1_btn.addEventListener(MouseEvent.CLICK, getSetup);
: t2_btn.addEventListener(MouseEvent.CLICK, getSetup);
: 呼叫同一个getSetup,但是set.text的值依按钮的不同而改变
: 当然写很多function是可以解决,但是这样就不用学了 = =
: 感谢指点!!
--
Dragon in Underware 3UB
Trample.
Any man creature become 0/1 weeky chiken.
If a woman deal damage to Dragon in Underware, Dragon in Underware become 0/1 weaky chiken.
If Dragon in Underware deal damage, put many 1/1 red Ooze token into play
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.138.32.78
※ 编辑: sledogerunir 来自: 140.138.32.78 (03/09 16:15)
1F:推 openyayak:GOOD^^ 03/09 16:56
2F:→ godsing:酷耶! 感谢!! 03/09 21:59