A Flash Developer Resource Site

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 31
  1. #1
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034

    Game Code Movieclip Optimization

    This was posted in the scripting and backend forum... but I think it would benifit more people here. I've picked out a few interesting paragraphs below, but take some time to read the whole article, its very interesting.

    http://flasm.sourceforge.net/#optimization

    the old "obsolete" flash 4 syntax still performs faster than nice dot scripts
    Why is flash 5-style coding slower than old flash 4 actions? Casper Shuirink found out the funny practice of flash player 5: new classes and methods are created internally using actionscript! Including string algorithms, array and movieclip methods - everything. Most of them are wrapped around flash 4 actions. Look into Caspers's findings. And again: it's not a visual representation, it's actual script used internally in flash 5.
    The worst example: myMC.gotoAndStop(), which is 25 times slower than tellTarget("myMC") gotoAndStop().
    Use tellTarget instead of with where possible.
    Avoid multiple parallel hitTest() functions in events - often seen in games. If the player is killed after any touch with an enemy, and you have 100 duplicated enemy clips, don't include any code in the enemy clip enterFrame event. Create the new mc and insert the enemy clip here. Then duplicate inside of this parent clip. Now you can check with only one hitTest() if the collision takes place. If you need to, use some custom math then to calculate what enemy was hit. Since most of the time no collision occurs, you'll make a really big improvement in fps.

  2. #2
    Senior Member devnull_2k's Avatar
    Join Date
    Oct 2001
    Location
    Limehouse, Ontario - Never heard of it? Not surprised.
    Posts
    785
    Wow, thank you very much.

    Although I already knew some of that, and some doesn't apply anymore (string and array functions were rewritten in C for MX i believe), it was very interesting.

    I will definately remember that tellTarget is faster than . syntax. Thanks!
    The future belongs to those who prepare for it today.

  3. #3
    Creator of Proximity
    Join Date
    Aug 2002
    Location
    Naperville, IL
    Posts
    28
    But but....dot notation is so much easier to read than tellTargets!

    I HATE tellTargets. I gladly got rid of them when Flash 5 came around.




    .....but if I absolutely need to optimize, I'll remember it, I guess.

  4. #4
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747
    It does seem odd that macromedia would knowingly make their code slower in a newer version - especially as it is so bad already!!! They must realise it isnt just used for 'flashy' websites...

    Urgh...

    fracture2 - the sequel
    fracture - retro shooter
    blog - games, design and the rest

    "2D is a format, not a limitation" -Luis Barriga

  5. #5
    Dot-Invader marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,600
    very informative, thank you.

    i don't like tell target either, but... well.

  6. #6
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Originally posted by random10122
    It does seem odd that macromedia would knowingly make their code slower in a newer version - especially as it is so bad already!!!
    Yup... I think its lazy coding... I don't want to get on macromedia's back here, I know it must be hard to rewrite the whole flash browser plugin, then again for different os's and again for different browsers, but most of the problems in the swf plugin are poor, or badly implemented, code related.

    Its also a speed issue, Macromedia launching a new version of flash every year or two must put some strain on their programmers, swfs must be back compatible as well, so I guess its just easier to slap more code on top of the old code.

    I'd rather not use telltarget either... but if it helps speed up my flash movies then I guess thats what I'll have to do!

  7. #7
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,001
    I'm willing to bet that director's lingo is no where near as slow as flash actionscript
    Last edited by BlinkOk; 10-13-2002 at 07:33 PM.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  8. #8
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Originally posted by BlinkOk
    I'm willing to bet that director's lingo is no where near as slow as flash actionscript
    Yup! But thats like compairing a mini cooper with a fully kitted out Audi R6

  9. #9
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,001
    i reckon it's product positioning
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  10. #10
    Senior Member devnull_2k's Avatar
    Join Date
    Oct 2001
    Location
    Limehouse, Ontario - Never heard of it? Not surprised.
    Posts
    785
    I kind of see it like this.

    Macromedia ways the pros and cons of writing all actionscript functions in C, and then decide. Since Flash is used to build games by a small part of the community, and in that community even fewer build games requiring fast calculations, its just not worth it.

    Director on the other hand is.
    The future belongs to those who prepare for it today.

  11. #11
    w00t PrED32's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    529
    All that has been fixed, so I have heard, with Flash MX... So unless your using Flash5 Player, you dont need to worry too much.

  12. #12
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Originally posted by PrED32
    All that has been fixed, so I have heard, with Flash MX... So unless your using Flash5 Player, you dont need to worry too much.
    What has been fixed in MX? All the speed issues? Not sure what you are reffering to?

  13. #13
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,001
    Slow is an understatement. see;
    http://nowhere.embryo.se/
    Look at "How slow is Flash ActionScript?"
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  14. #14
    w00t PrED32's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    529
    Flash 6 player has changed alot of the way it handles things...
    Alot of the classes have been rewritten in c++ instead of actionscript, and all the old function has been deprecated, as far as I have heard, in regards to the . syntax vs flash4 syntax, Flash 6 player has eliminated the slowness that Flash 5 has.

    In regards to Actionscript vs. other languages, it is alot slower, that is for sure.

  15. #15
    SaphuA mosterdfles_flash's Avatar
    Join Date
    Jan 2002
    Location
    Tha Couch
    Posts
    935
    Originally posted by BlinkOk
    Slow is an understatement. see;
    http://nowhere.embryo.se/
    Look at "How slow is Flash ActionScript?"
    LOL... that realy is 'slow'

    But, I think macromedia already knows these problems and should be working on it, maby they will give a free update or something

    But I just dont understand WHY telltargets are faster then the dot thing, I just think it's either the flashPLAYER or just flash whos making it slow (so i thin it's just some small error )

    Lets pray
    'How Art Is The Visual While We’re Artificial…'

    Mail & MSN
    My Not Finisched Page!
    Nick: SaphuA

  16. #16
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,001
    Why would they want to fix it when they can leave it the way it is and force people to spend more money buying director?
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  17. #17
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Like PrED said.. If I understood correctly(and remember correcyly =P), Macromedia has fixed all these issues.

    Including the awkward tellTarget() function.

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  18. #18
    w00t PrED32's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    529
    Okies...

    Apart from what alot of people think. Macromedia arent the bastards that you think they are...

    Director and Flash are two completely differnet platforms. Flash is more web-based, director (even thought having a web-based plugin) is aimed at standalone applications.

    Macromedia arent slowing flash down to improve sales for director, it would be obsurd to do such a thing.

    If Macromedia doesnt want Flash to be near Director, they would not have implemented actionScript to how it is today, infact they wouldnt have improved it over Flash 3... The proof is in the fact that Macromedia continue to improve Flash actionScript through each version.

    And finally, while i'm here... I'd like to point out that tellTarget is a piece of junk, heralding from the days in Flash3, when you wanted to control another movieClips play-head (play, stop, gotoandplay/stop) thats all telltarget used to do, I'm sure macromedia would have killed it in flash4 were in not that they didnt have another way of doing things... Sure I dont agree that they should have made the dot syntax of flash5 telltarget in disguise, but none the less, Flash 6 player is great, and is alot more speedy in comparison.

    /me takes a breath...

  19. #19
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    I agree.. Just look at the Flash improvements over the last few years. Then look at Directors improvements. Who's on top, do ya think?

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  20. #20
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Originally posted by mosterdfles_flash
    But I just dont understand WHY telltargets are faster then the dot thing, I just think it's either the flashPLAYER or just flash whos making it slow (so i thin it's just some small error )
    I thought its because the flash4 player was written from the ground up... and then the flash5 java syntax was bolted on top of that... then not wanting a full rewrite (lazy) they just assigned the _root.blah to the already functioning telltarget

    But who knows?!

    Does anyone know 100% for sure if these bugs are fixed in FlashPlayer6? Is there somewhere on macromedia.com we can look, or someone to pester with emails?

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