View Full Version : Game fps Issues

05-26-2002, 03:48 PM
OK...I have a game that contains about 12 animated movie clips, each controlled by actionscript. They consist of the following:

1. A "Field" movie clip that contains mouseDown and keyDown handlers
controlling basic quit commands and stuff
2. A "Piece" movie clip containing 9 "Block" movie clips and scripted with
simple x axis motion
3. Nine "Block" movie clips each containing a mouseDown handler to check
when they are clicked on
4. A "Crosshair" movie clip with an enterFrame handler to reset it to the
mouses current position

So my question is this...I get slowup...how do I get rid of it?? I don't see that this is too many handlers for Flash to handle or anything, but I want it to run at 30 fps or so and I'm currently getting about 10-15. The biggest issue is the crosshair, which produces noticeable slowup when in motion, but not when the mouse is still. This makes no sense to me since Flash should be setting the coordinates of the clip regardless of the motion of the mouse. Also, I suppose I could somehow alter my code so that the individual hit tests weren't assigned to "block", but instead existed in a for loop in "Field". That would knock out 9 handlers, but I want to know if this is worth doing before I start messing with all the target paths and such. And of course, I still have to add some additional code dealing with my matrices to check for when the "Block" movie clips "land", which is essentially 9 if statements in a for loop. THANKS!

Oh, and I can post the .fla if someone wants to see it...just let me know.

05-27-2002, 01:45 PM
That shouldn't be too many handlers, if you make your code efficient. EnterFrame in Flash 5 was the work of the Devil. In FlashMX we can delete the actions when they have served their purpose so they're not so bad.
In general:
- Anything you can do to minimize the use of hitTest is a good thing. Personally I try to avoid it as much as possible.
- You might consider little things like removing ourlines from shapes. An circle without a line around it animates much more easily than does a circle with a border.
- Consider using mouseMove as your crosshair trigger event in place of enterFrame.
.. ahh that's all I can think of. It's late at night.