2010-09-14 81 views
0

我有一個按鈕叫profile_btn我怎樣才能使這個代碼由oop

我想通過OOP這個代碼。

profile_btn.addEventListener(MouseEvent.CLICK,profile_btnClickHandler); 
function profile_btnClickHandler(ev:MouseEvent):void 
{ 
    //The actual code to jump to a specific frame 
    this.gotoAndPlay('play'); 
} 

另外,我怎麼能包括通過ActionScript3的三個類特定幀未與任何對象

+0

7號線\t 1046:類型未找到或不是編譯時間常數:profile_btn。 – john 2010-09-14 15:25:03

+0

profile_btn應該是舞臺上的一個按鈕的實例名稱.....對於剛剛提到的錯誤。 – loxxy 2010-09-14 15:26:19

+0

實例名稱'profile_btn'在類型爲profile_btn的對象上聲明,但在類型爲flash.display.SimpleButton的對象上存在實例名稱'profile_btn'的衝突使用。 – john 2010-09-14 15:26:29

回答

0

,如果你有一個類(你在連接時指定的名稱,可以使用以下)profile_btn。

var myButton:profile_btn =new profile_btn() 

如果你想將其添加到舞臺使用:

stage.addChild(myButton); 

所以,你的代碼可能如下

var myButton:profile_btn =new profile_btn() 

stage.addChild(myButton); 

myButton.addEventListener(MouseEvent.CLICK,profile_btnClickHandler); 

function profile_btnClickHandler(ev:MouseEvent):void 
{ 
    //The actual code to jump to a specific frame 
    this.gotoAndPlay('play'); 
} 
+0

我收到此錯誤錯誤:錯誤#1023:發生堆棧溢出。 \t在flash.display使用::影片剪輯/ GET currentScene() \t在用於fl.motion ::的AnimatorBase/handleEnterFrame() \t在btn_profile() – john 2010-09-14 15:47:43

+0

,以及如何通過ActionScript3的 – john 2010-09-14 15:49:44

+0

我不包括這個類在一個特定的幀沒有辦法,只需將按鈕的「class」值設置爲profile_btn即可。其餘代碼將自動引用並添加它。哦,確保你檢查「在第1幀中導出」和「在AS中導出」。 – loxxy 2010-09-14 15:54:13

相關問題