1

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,

Yan
  • 582
  • 2
  • 6
  • 22

1 Answers1

1

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));
    }
}
Max Dohme
  • 710
  • 5
  • 12
  • Just got an error 1046: Type was not found or was not a compile-time constant:customPreloader. Why is that? http://pastebin.com/JRBgFiGc – Yan Mar 06 '11 at 18:40
  • 1
    On line 13 you are defining cp as an object of the class "customPreloader", which I assume is your MovieClip. The error means the compiler doesn't know what class "customPreloader" is supposed to be. Are you sure you've set up the class correctly? Is it perhaps "CustomPreloader"? – Max Dohme Mar 06 '11 at 19:23