Re: [問題] 動態建立物件 如何替它建立事件呢?
※ 引述《panger (超脫歸心)》之銘言:
: 假設我先建立一個影片片段叫做"ball"
: 然後在屬性之中選擇 匯出actionScript使用
: 就變成了一個叫做ball的類別
: 我設立了一個按鈕,每按了一次,就會呼叫下列的函示
: 來建立一個ball的instance。
: function buttomDownListener(event:MouseEvent):void {
: var tempBall:ball;
: tempBall = new ball();
: addChild(tempBall);
tempBall.addEventListener(MouseEvent.MOUSE_DOWN,abc);
tempBall.addEventListener(MouseEvent.MOUSE_UP,abcD);
: }
function abc(e:MouseEvent):void {
tempBall.startDrag()
}
function abcD(e:MouseEvent):void {
tempBall.stopDrag()
}
這樣在執行過程之中,就可以建立很多的實體。
: 但是,我要怎麼替它們建立事件呢?
: 因為我想要讓他們每一個都可以被拖曳。
: 謝謝大家!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.170.204.223
討論串 (同標題文章)