Question : Actionscript 3.0 optimization, packages and enter_frame

I have a growing project where all of the scripting is currently contained in .as files. I have a fairly large Main.as and then 2 or 3 packages.

Should I move some of the other functions out of the Main.as file for optimization or is it better to have most of the functions in the Main file? I have read that class and package look ups are expensive on the CPU, but then again most of the AS3 source projects I look at are broken into many packages.

Also, I have several event listeners running looping processes on ENTER_FRAME in the Main.as. does this mean they are all on the first frame? Frames get a little vague to me when a project is all .as so I am curious the best way to approach those type of listeners for optimum performance and efficiency.


thanks.

Answer : Actionscript 3.0 optimization, packages and enter_frame

I think that package optimization doesn't really make much of a difference unless you are working with a project with 10+ packages. I would do whatever is easiest for you; I don't believe you would see much (if any) difference in resource consumption between the two.

As for ENTER_FRAME, that event is called whenever a new frame is entered. For example, when the movie moves from frame 8 to frame 9, an ENTER_FRAME event is called. This also applies to looping movies; that is, if a 1-frame-long movie goes from frame 1 to frame 1, it still fires an ENTER_FRAME event. Theoretically, this event should be fired at your movie's frame rate (i.e. 30fps means 30 events firing in 1 second, or one every .0333... seconds)

Personally. I don't like ENTER_FRAME. I would much rather use the flash.utils.Timer class. You have more control (stop/start/change tick rate on the fly) and it is slightly more accurate than ENTER_FRAME, which can vary if you are loading images or doing anything else processor-intensive.

You can read more about the Timer class here:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html
Random Solutions  
 
programming4us programming4us