A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Bad performance using scale?

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    6

    Bad performance using scale?

    Hi all!

    I'm trying to make a small game in Flash using ActionScript 3. On the scene there is a movieclip that can be moved around with the arrow keyes. Its also possible to zoom in and out. I use scaleX and scaleY for this.

    The problen is that the more I zoom in (scale up my movieclip) the slower it gets. Finally the cpu is 100% and it moves and scales very slow. If I zoom out again everything is back to normal.

    Why? Have I missed some trick? How to get around this problem?

    Tanks for any help!

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    Can you post the code? Unless this is just some kind of incredibly massive bitmap, that shouldn't be a problem unless there's an error in the math you're using to scale it...e.g. if you're connecting the scale to the motion of the mouse in some additive, looping way that causes it to expand exponentially; if you have any code in an EnterFrame that adds to the scaleX and scaleY based on the mouse's position, I would consider that suspect, unless it's based on the mouse's position relative to the position it was at when it received a mouseDown. If you can be more specific, I can help more.

  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    6
    Thanks!

    A have attached parts of my game project. If you can find the problem I'm very pleased. This is my first attempt to learn Flash and make some game...

    All files including my .fla is about 700k - the limits for files here is 300k - so I can't post it all here... maybe I can mail it to you somehow?

    It consists of quite some classes but the one of intrest is MilkTheVmsCow.as where the arrowkey events are handled, and the Cow.as where my movieclip is moved and scaled. I have comment out some parts of the code trying to find the problem myself.

    To see my problem run the MilkTheVmsCow.swf and use the arrow keys to move it around - no problem. Then hold down shift and use up and down arrowkey to zoom in and out. The more you zoom in the worse it gets...

    If I comment out the parts were I try to create some feeling of 3D when moving (I move parts within my movieclip relative to eachother) it's not much better...
    Attached Files Attached Files
    Last edited by - Zapp -; 09-01-2007 at 05:24 AM.

  4. #4
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    Well, I don't see a problem with the code...looks okay; I think the issue is with the bevels you have on the graphic having to render with each frame at a larger and larger size...I wouldn't use a vector graphic for this, basically, if you need those kinds of gradients in there...the overhead on re-rendering those is what's slowing you down, it's going to be a lot faster if it's just a large bitmap, believe it or not...

  5. #5
    Junior Member
    Join Date
    Aug 2007
    Posts
    6
    You are right!

    If I remove my bevels it's no problem. I guess I have skip bevels.

    Should all my movieclips consist of bitmaps instead of vektor grafics? And those bitmaps have all the shadings a s o... Feels a bit clumsy to design the game like that (hard to fine tune shapes a s o).

    I got another tip that I also will try:
    Did you try to add a mask in ActionScript to your top-most sprite/child? If Flash Player only thinks it needs to render the stage area and not the work area outside of the stage, you might see better performance. (I know that masking graphics that appear behind Flash Video greatly improve video playback/performance...)
    Thanks for all your help!!! Really appreciate it!

  6. #6
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    You also might get better performance if you expand the objects in Illustrator once the bevels are on; i.e. if the bevel is part of the fill, not being post-processed with every frame.
    The mask thing...I'm not actually sure if that'll work or not, but it's worth a try.
    Anyway, my pleasure to help, and please stick around and help out the newbies!

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