【问题标题】:1180: Call to a possibly undefined method gotoAndPlay1180:调用可能未定义的方法 gotoAndPlay
【发布时间】:2013-07-29 16:43:47
【问题描述】:

我有这个到目前为止工作的 AS3 脚本...

stop();

b1.addEventListener(MouseEvent.CLICK, Info001);
function Info001(event:MouseEvent):void {
gotoAndPlay(2);
}

X.addEventListener(MouseEvent.CLICK, Exit001);
function Exit001(e:MouseEvent) {
NativeApplication.nativeApplication.exit();
}

然后,我在 .fla 文件中添加了一个类...

package
{
    import flash.system.System;
    import flash.system.Capabilities;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.desktop.NativeApplication;
    import flash.utils.setTimeout;
    import com.hdi.nativeExtensions.NativeAds;
    import com.hdi.nativeExtensions.NativeAdsEvent; 

    public class Main extends Sprite
    {       
        public var na : NativeApplication;
        private var admobId:String = 'a1514b5ef85e336';


        public function Main()      
        {
            na = NativeApplication.nativeApplication;
            na.addEventListener('exiting',exit,false,0,true);
            na.addEventListener('deactivate',exit,false,0,true);

            if ( stage ){
                stage.scaleMode = 'noScale';
                stage.align = 'TL';
            }           

            if ( loaderInfo ){
                loaderInfo.addEventListener( Event.INIT, init, false, 0, true );
            } else {
                init(null);
            }
        }

(这里的课不完整……)

按钮停止工作... :-/

我尝试添加

import flash.events.MouseEvent;

但这还不够……如何让它发挥作用?

【问题讨论】:

  • 是有错误,还是什么都不做?
  • 这有点难以理解发生了什么。班级做什么?我从名称Main 中假设它应该是一个文档类,但是您在时间轴上还有​​代码吗?也正如 Jeff 所说,它是否给出了您在问题标题中所述的错误?
  • 该课程是针对 admob 的...错误是主题的标题...如果我发布整个课程会有帮助吗?

标签: actionscript-3 air


【解决方案1】:

如果您尝试在Main 中运行gotoAndPlay,它将抛出该错误,因为Sprites 没有时间线。如果是这样,请尝试扩展 MovieClip

【讨论】:

  • 好吧..我是全班的新手..我习惯在时间轴中使用 as3...所以,有没有办法让代码和时间轴一类?我不知道更多这些事情:-/
  • 我假设您已将Main 设置为您的文档类?通过编写Main extends Sprite,您是在告诉Flash 您的swf 基于Sprite,并且严格来说Sprites 没有gotoAndPlay 方法。只是尝试扩展MovieClip 吗?
  • 嗯...你介意告诉我如何扩展它吗?看来这有点像我们的联盟:-/
  • Main 类的顶部,您有public class Main extends Sprite。添加import flash.display.MovieClip 并改写public class Main extends MovieClip。您是否尝试过阅读课程?有a page about inheritance here
  • 成功了!谢谢你!如果我要去任何地方,我将不得不阅读有关类文件的信息……谢谢!又来了!
猜你喜欢
  • 2012-08-06
  • 1970-01-01
  • 2012-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多