2010-09-14 45 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

相关问题