A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Getting the best performance from flash, using curves???

  1. #1
    Flash Developer
    Join Date
    Jul 2008
    Location
    Scotland
    Posts
    106

    Getting the best performance from flash, using curves???

    Hi,

    I've been working on simple animation for a client, which you can see __here__.

    I have a few issues with performance. I have popped a fps counter at the top left and it seems to only run at around 30 fps on my laptop, I need it up to 60 though.

    i was just wondering if anyone had any tips about getting the best performance from flash.

    I have used Shape instead of Sprite on the curves, which gave a slight improvement. Surprisingly I didnt notice any change in performance when I dont use the blur filter on the curves, which was odd to me.

    Anyways, anyone got any tips for improving performance at all. I have had a quick search on google and got a few results, but nothing outstanding.


    Cheers

  2. #2
    Member
    Join Date
    Jan 2009
    Posts
    90
    It's very pretty, but without knowing how you've currently got it coded, it's hard to offer specific recommendations.

    What operations are you executing every frame?

  3. #3
    Flash Developer
    Join Date
    Jul 2008
    Location
    Scotland
    Posts
    106
    Basically, Ive got a curve class which 'dies' after 3 secs and Ijust create a new curve class with a timer in random positions. The positions are controlled by 3 bouncing balls which control the points of where to plot the curve. Theres nothing too difficult in my implementation, I wanted to keep it simple.

    Its in a puremvc project so I have just hacked out the basic bits.

    This is where I am creating the curves,

    Code:
    var b1:Ball = balls[0];
    var b2:Ball = balls[1];
    var b3:Ball = balls[2];
    
    var curve:DyingCurve=new DyingCurve(b1.x,b1.y,300,300,b3.x,b3.y);

    and the DyingCurve class is just a basic curve with some tweens on the alpha and it removes itself with

    Code:
    this.parent.removeChild(this);
    is removeChild the best garbage collection in flash?

  4. #4
    Member
    Join Date
    Jan 2009
    Posts
    90
    So each individual curve, once drawn, doesn't move at all? If so, I think what you want to do is draw one curve per frame and then render it to a bitmap and apply a colortransform to the bitmapData. That should get you over 100fps easily.

  5. #5
    Member
    Join Date
    Jan 2009
    Posts
    90
    The code for that would looks something like:

    In your setup, create a bitmap and a colortransform object. Something like:
    PHP Code:
    var bmpData:BitmapData = new BitmapData(800,800,true,0x00000000);
    myBitmap = new Bitmap(bmpData);
    myColortransform = new ColorTransform(1,1,1,1,5,5,1,-4); 
    Each frame, after you've drawn a curve to your shape (clear the shape.graphics first):

    PHP Code:
    // Assume shape has your curve drawn to it:
    myBitmap.bitmapData.draw(myShape)
    myBitmap.bitmapData.colorTransform(myColortransform

  6. #6
    Flash Developer
    Join Date
    Jul 2008
    Location
    Scotland
    Posts
    106
    Yea i tried this method but it was rendering strangley. It seemed as though flash was having an issue sorting the images properly because there was so many of them. I think I have found a quicker solution to getting this effect. Some pixel bender magic

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