The purpose of this section is to outline some general knowledge and flash code we have come to hold as pretty important stuff. Lot's of this stuff can be found on the net in some place or other. It's all "old school" AS2 stuff so handle with care...
 |
General Flash Game Tips |
1. Don't over complicate! Things just have to "look" like they work, don't concern yourself with making a physics engine if you just want to move something across the screen or detect collisions.
2. Reuse stuff. That's a no brainer, but still it's important when doing multiple projects.
3. Try to avoid scaling... it's a cool effect, but can drastically effect your frame rate.
4. USE MCTWEEN! It's much faster than doing Flash tweens and you can do some sweet stuff with it!
5. Flash 8 Filters ROCK! Try not to use them. They really eat up CPU time.
 |
Bits 'o' Code |
Basic "better" collision:
The basic flash hitTest method is pretty slick it works like this:
Simple enough to understand, test one object against another... HOWEVER, this method uses the bounding rect (the blue square you see in flash when an object is selected) as the collision test. Often times this looks horrible in flash and can be quite the pain to work around.
The simple solution is make a movie clip that is 50x50. Open your object that is going to be in the hitTest method and drag your new 50x50 movie clip in there. This is going to be our collision movie clip.
Now scale your collision movie clip to be smaller than the area of the object slightly.
Next, make your collision movie clip's alpha = 0 and name it something like "col".
Repeat this for any object you are going to check collisions against. Now edit your hitTest code like this:
Notice the ".col" appended to the ends of our movie clips names AND TADA! Now you have the poor man's way of faking decent collisions and still get to use the easy hitTest method Flash provides!
Turn any Movie Clip into a button:
There are 2 ways:
1. With a Movie Clip already placed on the stage:
|