Subhash k
Subhash k

Reputation: 391

Incredibly slow performance when going to previous frame of a SWF movie

In a SWF file, when I am using the following code to move backwards to a previous frame, it is incredibly slow -- Taking around 2 seconds. Where as moving forward to next frame takes 30-40 milli seconds.

movieClip.gotoAndStop(movieClip.totalFrames);//go the last frame of movie

while(movieClip.currentFrame>1) {
   var initTime:int = getTimer();
    movieClip.prevFrame();
    trace("Frame: "+movieClip.currentFrame+" Time taken:"+(getTimer()-initTime)/1000)        
 }

Here is the output i am getting (timings in seconds)

Frame: 84 Time taken:2.586
Frame: 83 Time taken:2.766
Frame: 82 Time taken:2.257
Frame: 81 Time taken:2.447

The SWF movie is generated from a PDF using SWFTools.

Size of the file : 5.8 MB Number of Frames : 85

Any ideas on what to do differently to improve the performance of going to previous frame ?

Upvotes: 0

Views: 230

Answers (2)

Marcelo Idemax
Marcelo Idemax

Reputation: 2810

I reported this issue today on Adobe Jira:

http://bugs.adobe.com/jira/browse/ASL-313

Upvotes: 1

weltraumpirat
weltraumpirat

Reputation: 22604

Anyway: Using a while() loop to jump trough frames is not a good idea - the player will try to execute the instructions during one frame's time, while each MovieClip frame should be displayed for a long enough time to be registered by the human eye. Have you tried this instead:

movieClip.gotoAndStop(movieClip.totalFrames);//go the last frame of movie

var timer : Timer = new Timer (100,999);
timer.addEventListener (TimerEvent.TIMER, , function () : void {
    var initTime:int = getTimer();
    movieClip.prevFrame();
    trace("Frame: "+movieClip.currentFrame+" Time taken:"+(getTimer()-initTime)/1000)        
});
timer.start();

Using Timer instead of a loop assures that switching between the actual frames takes long enough for each frame to be displayed properly - and for the function to stay within reasonable performance boundaries.

Upvotes: 0

Related Questions