Methods of Lag reduction.

12 posts

Flag Post

What can I do? I have tried quality, making offscreen mc’s invisible, mute, removing big mcs completely after they play, and making images have a lower filesize. Remember, the filesize isn’t the problem, the lag is.

 
Flag Post

Also make sure you have no more than one (1) onEnterFrame method running at any given time, which means not using onClipEvents at all (not that you would do that, of course ^^).

I had always believed that if you had a “pool” of objects, (i.e. not removing MovieClips when they are not needed but moving them to -1000x, -1000y and making them invisible), and you also had a mask over your main stage which was applied programmatically, the player wouldn’t try to render those clips. Recently I have heard opinions to the contrary, but I still want to believe :)

Reducing the amount of lines you use is important too. Fills are easier for Flash to render, so try the “convert lines to fills” command on all your stuff too.

And don’t forget, among the other things that people will mention, writing efficient code is paramount to performance. You should know exactly what the player is trying to process on any given frame, so you can keep it reasonable.

This is something I’m also really concerned about, so I would love to see if anyone else has better suggestions :)

 
Flag Post

Well, you see I have been making this game for a while. 2 and a half years. I was not as good with Actionscript back then, so I placed an onclipevent on just about everything. Would there be a way to replace all instances of onclipevent in flash with whatever else?

 
Flag Post

You would have to change the whole thing yourself, there’s nothing that just turns onclipevents to enterframes without doing a lot of work. Also, another method of lag reduction is to not have a lot of things with partial transparancy on the screen at the same time, and to turn lots of stuff into bitmaps.

 
Flag Post

Ah, I see. Well, what you want to do is take all the code out from your various MovieClips, and put it on the main timeline. Then you will need to give the clips instance names and scope all of the code properly to perform at the _root timeline.

Yeah, Woad is right, also. Alpha transparency really slows things down, so use it sparingly. Also if you are using any filters (such as blur, glow, etc.) try to determine whether you really need them or not, because they are resource-intensive.

 
Flag Post

Lots of stuff is not a factor. I have 10s of things onscreen at a time. I just thought they wouldn’t effect lag if I made offscreen ones (hundreds) invisible.

 
Flag Post

Objects that are offscreen and invisible still take resources. Dont create the objects until you need them.

 
Flag Post

Thanks for clarifying that coder ;)

Apparently a good method to use, in lieu of moving things off screen and making them invisible (or in addition to), is setting the timeline of the Movieclip in question to a blank keyframe, so the Flash player isn’t even tempted to render it.

I’m going back right now in my game (over 700 objects in my library total) and adding this functionality to it to see if i can get a performance boost. Fortunately, I used a lot of classes in the game and because of that it will be a lot easier to make changes like this.

 
Flag Post

I am personally attempting to not use more than 2 movieclips in my current game development, through the use of a blitting / double buffering bitmap class. This is not something you would want to do to an existing game, but I am hoping this method of developement will enable stable frame rates on older computers even with many things on the screen at once.

 
Flag Post

if you got collision tests with mutliple objects, check you loop range (for & while), so it doesn’t check mc you already deleted or out of range.

 
Flag Post

just for the case you weren’t there Actionscript optimizations tutorial at gotoandplay.it

 
Flag Post

Nice. Too bad AS3 is on the horizon and I think I should start learning optimizations for that instead :)