dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] gotoAnd* performance

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    175

    [F8] gotoAnd* performance

    This has been confusing me: in my current project, it looks like the gotoAnd* calls incur a pretty high cost. One example: I had a character animation where the head was in the same movie clip as the body and they animated on different layers, but I needed to make it so that sometimes the head would be drawn above the body and sometimes below. The first solution I thought of was to put the head's animation in a separate movie clip, create two copies (one below and one above the body, changing which is visible), then just use gotoAndStop() to synchronize the head frame with the body frame. The performance hit was enormous (many copies of this character are on screen at once). So I tried moving the animation back into the same clip as the body, and just creating two identical copies on different layers. The performance was fine. Was gotoAndStop() the difference? What was making it go so slowly?

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I have never heard of any gotoAnd* action taking up resources/performance liek that.. and I dont see why..its a simple command..nothing to do before or after it.


    alternately.. maybe keep the head in its OWN clip..and swap the depths of it instead.. so its the same clip..but on a depth either above or below the body clip.

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    175
    I tried doing it a third way without gotoAndStop and once again it performed, much to my surprise, quite poorly: I created an array specifying the Y-values the head should be at at each frame, and then onEnterFrame() I move the eyes to the correct frame. It did about the same as with gotoAndStop, a drop from about 30 to 20 fps :P I'm very confused because I wouldn't expect there to be much difference internally between having the Y-value set by the keyframe and having it set by a script. The only thing I can think of right now is that maybe Flash can do some caching with frames that are predefined but as soon as you throw movie clips in it's unable. There's a lot of gradients, transparency, and scaling going on, so maybe I just got lucky that it ever went at a reasonable speed to begin with.

    Unfortunately, it would be difficult to use different depths for different parts of the character. The game is 3D and has to be depth sorted, so the options would be changing the depth sorter to reserve multiple levels for certain objects (wrote it long ago, don't want to mess with it :P) or to enter the objects separately, which would not be good for performance.

  4. #4
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    onEnterFrames() are almost always a culprit for code running slow. only use then in controlled environments.. dont have them just running for no reason.

    gradients and transparency also eat up CPU.. also it should be a big factor..but I have no idea how your 'movie' is set up.

    anyways.. good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center