0
votes

I've got a movieclip that is composed of 3 separate symbols. 2 of the symbols have their alpha tweened over 60 frames. 1 of the symbols is not tweened at all. All symbols are in separate layers, and there is a 4th, empty layer with a keyframe on frame 60 for actionscript.

The actionscript on frame 60 is simply "stop();" .

I am adding an instance of the movieclip to the stage dynamically from the document class. When I have "stop();" in there, the movieclip appears on the stage and skips straight to frame 60, where it succesfully stops.

Without "stop();" in there, the movieclip plays the alpha tweens perfectly, but obviously continuously loops.

Manually dispatching an Event.COMPLETE and listening for it does not work either and I would prefer not doing it that way anyway.

Here is the code that adds the movieclip to the stage:

//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;
        }




    }

The movieclip's class is tidepool_gameboard and the property of the document class that stores the reference to it is game_board.

Any idea why putting stop(); on frame 60 of the movie clip is causing it to skip to the end without tweening?

UPDATE:

Adding the movieclip to the stage instantly instead of as the result of an event listener works properly, the problem only occurs when the movieclip is added in the event listner.

1
You may want to upload a small .fla that reproduces this problem. Timeline-related issues are very hard to examine without the timeline. There may be something off with the timeline that you overlooked and didn't include in your description.xxbbcc
@xxbbcc I have been attempting to re-create the problem in a smaller, demo FLA file. I cannot seem to reproduce it, however the problem persists in the full file. I would upload it but it is very large and inconvenient... even the stripped down demo is 15MB - everything is 1080p and there are dozens of images that build this symbol.BumbleShrimp

1 Answers

0
votes

I can't believe I overlooked this, as it appears to be fairly obvious to me now.

In the code posted in the question, I've initialized a new instance of this.game_board, then added it to the stage after a delay based on an event listener for a video clip. The animation is playing, but it's playing before the clip ever is added to the stage.

Thanks go to alecmce who answered this question.

I did his Event.ADDED_TO_STAGE event listener, and it worked, which led me to realize that the MovieClip does not wait until it is added to the stage to start playing its own timeline, it simply starts the second you instantiate the object.

This is the new, fully functional code:

    //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;
        }
    }