flash q
- Started
- Last post
- 17 Responses
- imakedesign
can the position of code effect performance?
so should i be putting all my critical functions at the top of the code? this might be a silly question.
- uberdesigner0
it's a good habit to put your functions first and call them throughout the timeline, it's also probably a little faster
- imakedesign0
thanks, all my code is on one frame tho..
- uberdesigner0
if everything's in one frame, then it probably doesn't matter
- imakedesign0
ok cheers, do you know of any other useful optimization tips? trying to speed up my code.
- uberdesigner0
use .prototype when calling clips
- Solid0
Sometimes it depends on what the site is doing - eg. is it a game, a photo viewer etc.
1/ Build in garbage collection and clean up routines into your functions/classes. For example delete unecessary variables, objects, etc. that are no longer being used.
2/ Try not to make unecessary or excessive function calls.
3/ Clean up unused onEnterFrame and setInterval processes (related to #1).
- jDs0
Solid has it - be dilligent about trash collection.
Also, comment A LOT and CLEARLY. This will not speed performance of the machine per se, but 6 months down the line it'll save you serious digging in your code...'what was I doing here again? Oh s__t, why did I do this this way??'
More important to save yourself and fellow developers [if you have any] than your greedy processor.
- imakedesign0
thanks for the tips guys !
Try not to make unecessary or excessive function calls
Solid
(May 31 05, 15:01)so is it better to wrap everything up in functions or execute directly?
- Solid0
so is it better to wrap everything up in functions or execute directly?
imakedesign
--------I would recommend using functions in your project.
The key is to design your functions to be efficient. Why call a function repeatedly if you can design your app in a way that requires only one function call (although this isn't always the best approach either ..).
Also (without turning this into an OOP discussion) start thinking about the relationships between your functions, as well as the "why" in the way you break up your code into functions.
Eg. what should or shouldn't be written as a separate function? How do these functions relate to each other, work together, etc.
- imakedesign0
hmm.. many thanks i will mull this all over.
- Solid0
Its a lot to take in if you don't come from a programming background.
Try starting here:
http://tinyurl.com/eymwj;)
- imakedesign0
yeah i have been thinking about picking that one up seems to get recommended alot.
does any one use external AS editors and if so which ones?
- caseyc0
Here's a great resource for AS performance tips, etc...
- jmteow0
" 3/ Clean up unused onEnterFrame and setInterval processes (related to #1)."
How does one clean up unused onEnterFrame sequences?
That's something I unfortunately haven't been able to figured out.
- imakedesign0
delete.this onEnterFrame
- dijitaq0
delete this.onEnterFrame;
- afxrephlex0
making your code more readable or tidier will not boost up the performance that much.
Instead implement a faster algorithm.
check this:
http://en.wikipedia.org/wiki/Com…