Search code examples
actionscript-3flex4flash-buildermovieclippreloader

Play movieClip before initialize


So I have a custom preloader with 200 frames and the corresponding in Flex:

gotoAndStop(Math.ceil(e.bytesLoaded/e.bytesTotal*100));

So basically each procent is one frame in the movieClip. So when 100% the movie ends and application initializes.

How can I say for example so that when 100% don't start the app but play from frame 100-200 in the movieClip and then initialize the app?

Thanks,


Solution

  • How about adding an event listener when loading is complete, then displaying the MovieClip frame one after another from 100-200. When that is done, you can dispatch the complete event.

    private var _currentFrame:int;
    
    private function initComplete(e:Event):void
    {
        _currentFrame = 100;
        addEventListener( Event.ENTER_FRAME, onEnterFrame );
    }
    
    private function onEnterFrame( e:Event ):void {
        if ( _currentFrame < 200 ) {
            _currentFrame++;
            cp.gotoAndStop( _currentFrame );
        } else {
            removeEventListener( Event.ENTER_FRAME, onEnterFrame );
            dispatchEvent(new Event(Event.COMPLETE));
        }
    }