0

我有一个由 3 个独立符号组成的影片剪辑。其中 2 个符号的 alpha 补间超过 60 帧。1 个符号根本没有补间。所有符号都位于单独的图层中,并且在第 60 帧上有一个带有关键帧的第 4 个空图层,用于操作脚本。

第 60 帧上的动作脚本只是“stop();” .

我正在从文档类动态地将影片剪辑的实例添加到舞台。当我有“stop();” 在那里,影片剪辑出现在舞台上并直接跳到第 60 帧,并成功停止。

没有“停止();” 在那里,movieclip 完美地播放了 alpha 补间,但显然是连续循环的。

手动调度 Event.COMPLETE 并监听它也不起作用,我也不希望那样做。

这是将影片剪辑添加到舞台的代码:

//initialize the gameplay, remove title screen.
    private function initialize_gameplay():void
    {

        //remove the title screen
        initialize_title_screen(true);

        this.screen_transition_obj  = new tide_out_video();         
        this.addChild(this.screen_transition_obj);

        this.game_board = new tidepool_gameboard();

        this.screen_transition_obj.addEventListener(Event.COMPLETE,swap_transition_video_for_screen);

    }

    //replace the current transition video with the screen it was transitioning to
    private function swap_transition_video_for_screen(e:Event){

        this.addChild(this.game_board);

        if(this.screen_transition_obj != null){
            if(this.getChildByName(this.screen_transition_obj.name)){
                this.removeChild(this.screen_transition_obj);
            }
            this.screen_transition_obj.removeEventListener(Event.COMPLETE, swap_transition_video_for_screen);
            this.screen_transition_obj = null;
        }




    }

影片剪辑的类是tidepool_gameboard,存储对它的引用的文档类的属性是game_board

知道为什么要放置stop(); 在影片剪辑的第 60 帧上导致它跳到结尾而不进行补间?

更新:

立即将影片剪辑添加到舞台,而不是作为事件侦听器的结果正常工作,只有在事件侦听器中添加影片剪辑时才会出现问题。

4

1 回答 1

0

我不敢相信我忽略了这一点,因为它现在对我来说似乎相当明显。

在问题中发布的代码中,我初始化了this.game_board的一个新实例,然后在基于视频剪辑的事件侦听器延迟后将其添加到舞台。动画正在播放,但它是在剪辑添加到舞台之前播放的。

感谢回答这个问题的alecmce 。

我做了他的 Event.ADDED_TO_STAGE 事件监听器,它起作用了,这让我意识到,MovieClip 不会等到它被添加到舞台上才开始播放自己的时间线,它只是在您实例化对象的那一刻开始。

这是新的、功能齐全的代码:

    //initialize the gameplay, remove title screen.
    private function initialize_gameplay():void
    {

        //remove the title screen
        initialize_title_screen(true);

        this.screen_transition_obj  = new tide_out_video();
        this.addChild(this.screen_transition_obj);

        this.screen_transition_obj.addEventListener(Event.COMPLETE,swap_transition_video_for_screen);

    }



    //replace the current transition video with the screen it was transitioning to
    private function swap_transition_video_for_screen(e:Event)
    {

        this.game_board = new tidepool_gameboard();
        this.addChild(this.game_board);



        if (this.screen_transition_obj != null)
        {
            if (this.getChildByName(this.screen_transition_obj.name))
            {
                this.removeChild(this.screen_transition_obj);
            }
            this.screen_transition_obj.removeEventListener(Event.COMPLETE, swap_transition_video_for_screen);
            this.screen_transition_obj = null;
        }
    }
于 2012-05-11T16:55:58.373 回答