dcsimg
A Flash Developer Resource Site

Page 16 of 21 FirstFirst ... 6121314151617181920 ... LastLast
Results 301 to 320 of 411

Thread: Optimization Tips

  1. #301
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    I think the problem with your demo is that your moving it all in the same frame.

    However the frame only gets drawn once.

    So the timer is only timing the moving code, it has nothing to do with the actual graphics.

    A test on graphic drawing times would have to be over time, say 500 clips moving up and down at the same time, and the getTimer() difference over 500 frames.
    Christopher Rhodes
    squarecircleco.

  2. #302
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335
    ah right, this time I had 100 identical clips all moving 1 pixel at a time looping over 600 frames and timing the total time taken at 24fps.
    Again, I ran each one 5 times and took the average.

    Results:
    gif - no transparency - 26.28s
    gif - with transparency - 26.28s
    bmp - 26.21s
    traced bmp - 27.21s
    bmp - break apart - 26.27s
    png - no alpha - 26.22s
    png - with alpha - 26.24s
    jpeg - low quality - 26.21s
    jpeg - high quality - 26.22s
    simple vector with outline - 26.24s

  3. #303
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335
    Squize - on your first post to this thread I think, you said about defining var p=_parent as a local variable within mc's.
    would this idea also help in frame code as well? (ie. could I use r=_root in my setup frame and then replace all occurences of _root with r?) is this still faster?

    cheers

  4. #304
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Yup, defining references as local variables is faster.
    Christopher Rhodes
    squarecircleco.

  5. #305
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    From Jobe's new book:
    if you are using gifs in your game, right click on them, choose properties, and uncheck 'Allow Smoothing'.

  6. #306
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    712
    I never was sure what that does actually. Does smoothing anti-alias the image if it's not on exact pixel coordinates?

  7. #307
    Senior Member youmex's Avatar
    Join Date
    Apr 2004
    Location
    Dortmund, Germany
    Posts
    176
    If smoothing is enables the Grafik will be smoothed at quality level "HIGH" as long as does not move and is in no movie. If you switch to "BEST" quality is will also be smoothed, no matter if it is a geaphic symbol or movieclip or if it does move or not.
    Be a worm and catch fruits in a parallax scenario:

    http://www.nibbly.com/flug.html

  8. #308
    Following on from the tips in this thread - would it be quicker to define all the built-in functions as global variables, say for an tile engine that uses onEnterFrames?

    _global.k = keyDown;

    If Flash checks the keyboard once every frame (as I think I've read here) then you could write the value into another global variable once and check that throughout your code?
    Mark Hardisty
    Red7 Design
    ========================================
    Red7 Design
    Starsky and Hutch
    ========================================

  9. #309
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    sorry, Kirill M, didnt see your post...

    If you take a bitmap in flash, and stretch it a lot, you'll see smoothing very clearly because the bitmap will look blurred instead of pixelated. Flash does that to almost every bitmap, even if it the right size. It's safer to have the allow smoothing off so flash doesnt waste time doing that.

  10. #310
    Anyone any comments on the single read of a key to a global variable idea?
    Mark Hardisty
    Red7 Design
    ========================================
    Red7 Design
    Starsky and Hutch
    ========================================

  11. #311
    Member
    Join Date
    May 2004
    Location
    Raleigh NC
    Posts
    34
    so when defining functions,i should name a reference like r= _root
    at the beginning of the func?
    (if it uses _root more than once)
    so there!

  12. #312
    jtnw's Avatar
    Join Date
    May 2002
    Posts
    1,328
    Yes, infact to spped it up more, use:
    code:
    var r = _root;



    jtnw

  13. #313
    Flash hates me. crashlanding's Avatar
    Join Date
    Nov 2003
    Location
    UK
    Posts
    439
    in a recent thread it was discovered that in flash mx, if-else is faster than switch, but in mx2k4 switch is faster.
    "wen i found my gerbil dead my other gerbil was eating it i just cried and screamed"
    http://www.livescripts.net

    --------------------------------------------------------------------------------
    Last edited by some moderator : Today at 9:01 PM.

  14. #314
    Senior Member
    Join Date
    Aug 2001
    Location
    Philippines
    Posts
    515
    Ok, I read through a lot of replies, but obviously, not all.

    I'm making a photoslideshow, and i need to optimize it.

    Please check out www.quirkworks.net - photography section. I have many movieclips and when I resize them it starts slowing down. I tried using _visible = false when they're not seen, but it didn't make much of a difference.

    Can anyone help?
    Ramon Miguel M. Tayag

  15. #315
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    the slowing down will occur even it's only one picture. But you could do:
    1) Instead of a smooth slider, make one which jumps to specific spots like 50% > 75% > 100 % etc and then scale the pics to that size. OR
    2) you could have a smooth slider but you dont see the effects onscreen immediatly so the pic is small, you drag the slider, it's still small, you let go, it becomes big OR
    3) you could reduce the quality of the pic or blacken it out while its scrolling. To do the blacking out thing: you have the pic, then you have an invisible movieclip on it that's just a black box. When you start dragging the slider, the black box is visible and that scales instead of the picture. As soon as you let go, the black box is again invisible and the pic is scaled to the size of the black box.

    Cant really help you in a way that would let you keep the look as it is though

  16. #316
    Senior Member
    Join Date
    Aug 2001
    Location
    Philippines
    Posts
    515
    i tried one picture and it worked like a charm.. real quick. it was ok til around 15 pics.

    this is how i implemented the change of size:

    1) whenever the slider is onPress, there's an interval that has a for loop (from 1 to, in this case, 24) which changes everything that needs to be changed.

    2) i call the movieclips by saying, for example, this["mc" + i]._xscale... etc, in the for loop.

    3) and update everything..

    might this be too consuming for the computer? i read somewhere that a linked list is way faster. Is that true? I'd like to confirm of course before I start making big changes.
    Ramon Miguel M. Tayag

  17. #317
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    a for loop is usually bad for the computer, but unless you use one of the other suggestions I've given, I dont know of any other way to do it. Also, my ways will also require a for loop too, but the loop will not run as often or will not have as much in it, thus making it faster. I dont really know about linked lists though, I'd definitely ask about that.

  18. #318
    flash mangler drunkenmaster2000's Avatar
    Join Date
    Apr 2001
    Location
    England
    Posts
    156
    Hello. I've been reading this thread today, and picked up a hell of a lot of pointers.

    So I though I'd give one back:

    multiple easing

    I am working on a lot of math-drawn stuff in flash, and the current one I'm working on, while very attractive, runs like a pig. Part of the reason, I was sure, was all the easing I was using (thanks Mr. Penner ) Every frame, this would get run by each of the mc's:

    code:

    _x = Math.easeinoutquad(currframe, fromx, tox, dur);
    _y = Math.easeinoutquad(currframe, fromy, toy, dur);
    scale = Math.easeinoutquad(currframe, fromh, toh, dur);
    newr = Math.easeinoutexpo(currframe, fromr, tor, dur)
    newg = Math.easeinoutexpo(currframe, fromg, tog, dur)
    newb = Math.easeinoutexpo(currframe, fromb, tob, dur)



    After running the block of code through a timer I tried this:

    code:

    quad = Math.easeinoutquad(currframe, 0, 1, dur);
    expo = Math.easeinoutexpo(currframe, 0, 1, dur);
    _x = fromx+(tox*quad);
    _y = fromy+(toy*quad);
    scale = fromh+(toh*quad);
    newr = fromr+(tor*expo);
    newg = fromg+(tog*expo);
    newb = fromb+(tob*expo);



    It cut about 40% of the time taken.

    code:

    expo = Math.easeinoutexpo(currframe, 0, 1, dur);
    _x = fromx+(tox*expo);
    _y = fromy+(toy*expo);
    scale = fromh+(toh*expo);
    newr = fromr+(tor*expo);
    newg = fromg+(tog*expo);
    newb = fromb+(tob*expo);



    This one cut about 60%, but reduces my choices somewhat.

    So there you go.

    Basically, you just have a 'master' easing variable, for everything that will share that particular set of easing variables.

    Hope this helps someone.

    Now I gotta go declare about a million variables

  19. #319
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,367
    Edit: Optimization wrong, whoops...
    Added:
    I also just did a speed test to see how much faster function pointers are than an if with a function inside...
    code:

    //Approximately 470ms-495ms on my comp

    t = getTimer();
    f=6
    t=10
    function frog4 () {}
    for (var i = 0; i<10000; i++) {
    // one.hitCheck(two);
    // one.hitCheckNoBounds(two);
    // one.distanceSquared(two)
    the=t-f
    if(the==4){
    frog4()}


    }
    trace(getTimer()-t);

    //while....
    //this is about 320ms normally, a gain of 170ms, not bad if used a lot....

    t = getTimer();
    f=6
    t=10
    function frog4 () {}
    for (var i = 0; i<10000; i++) {
    // one.hitCheck(two);
    // one.hitCheckNoBounds(two);
    // one.distanceSquared(two)

    the=t-f
    what="frog"+the
    what()
    }
    trace(getTimer()-t);



    Just my two cents for this year
    Last edited by UnknownGuy; 01-09-2005 at 09:34 PM.

  20. #320
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407
    How do I check if any of my 100 clips hitTest another with help of a optimized for loop ?

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