1

我正在开发一个 Flash 项目,我的所有代码都在一个外部 Document.as 文件中。

我将如何设置一个在加载其他 MovieClip 之前运行和完成的介绍 MovieClip?现在发生的情况是剪辑与 Document 类中的所有其他内容(内容、UI...等)一起加载。我希望介绍剪辑运行、停止然后继续 Document 中的其余代码。

我已经尝试stop在剪辑上使用该方法,但它似乎什么也没做,只是将 MovieClip 放入播放循环中。

谢谢。

4

2 回答 2

1

在您的文档类中,您可以访问可以在时间线的第一帧中找到的任何影片剪辑。例如,实例名称为“myClip”的影片剪辑放置在第一帧中,您可以使用以下代码访问它:

package  
{
    import flash.events.Event;
    import flash.display.MovieClip;

    public class Document extends MovieClip 
    {
        public var myClip:MovieClip;

        public function Document()
        {
            addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event) : void 
        {
            myClip.stop();
        }
    }
}

另一方面,您可以在 Flash 中从时间线访问您的文档类范围。调用 Document "functionAtDocument" 中定义的公共函数如下所示:

Document(this).functionAtDocument();

您的 Document 类中的代码:

package  
{
    import flash.display.MovieClip;

    public class Document extends MovieClip 
    {
        // ... missing some code
        public function tracer():void
        {
            trace ('call from flash timeline');
        }
    }
}

考虑到这一点,我认为您可以前后移动,将时间线中的值发送到类,并操作那里的任何电影剪辑。

于 2010-01-19T15:40:10.450 回答
1

您可以使用停止动作来定位介绍影片剪辑。但我会建议这样的事情:

class documentOfFLa extends Sprite {
     public var introMC:MovieClip;           // the introduction animation
     public var restOfAnimation:MovieClip;   // whatever is after the intro
     function documentOfFLa() {              // constructor
          introMC.play();
          restOfAnimation.stop();
     }
     public function continueParent():void {  // call this at end of intro
          restOfAnimation.play();
          introMC.stop();
          removeChild(introMC);
     }
}

...在介绍动画结束时,在时间轴上调用类似这样的内容:

this.parent["continueParent"]();

我知道这是 hack-ish,但它会很快实施。然后你可以清理它...

于 2010-01-19T15:41:22.037 回答