As I said before, I am going to note some tricks, and some of the stranger hangups that we have run into to try to make life easier on others that are programming in Actionscript 3. Some of these things may already be familiar to the reader, but these things have come up as really strange/different to me working with Java and C before this, and never really working with graphics.
First off, Flash arrays are dynamic. In both Java and C, code like this would just break, but not in Flash:
var fooArray:Array = new Array("foo", "bar");
fooArray[2] = "foobar";
However, in Flash, this works and returning the array would give you “foo”, “bar”, “foobar”. Really handy stuff.
An array has the length of the number of elements in the array, not the maximum length of the array, or the largest element that the array gets to. Also, interestingly enough, an empty array has length 1. Flipping a Sprite or movie clip about an axis is actually rather simple.
movieClip.scaleX = -p;
multiples the width of the object by p, then flips it about the y-axis.
The trigonometric functions return radians. Keep this in mind if you try to use one of these functions to help you rotate an object.
The last one that comes to mind is the frustrating one about trying to get an array of movieClips:
mcArray[i] = new movieClip();
//set properties of the movieClip as needed
stage.addChild(mcArray[i]);
breaks to pieces, especially when you are trying to use a class that inherits from movieClip. What you need to do instead is to store the movieClip into a temporary variable:
var tempClip:movieClip = new movieClip();
//set the properties of the movieClip
stage.addChild(tempClip);
mcArray[i] = tempClip;
I suspect that when you put it directly into the array, it “forgets” that it’s a movieClip, because the elements of an array are untyped until something is put into an element, and then when you call a function, like addChild, which relies on a movieClip, you get an error that screams that you are trying to coerce a variable into a movieClip when it either is a movieClip, or inherits from a movieClip. Strangely enough, the first code works fine for Sprites.
I hope this was at least a little useful, and as I work on the StatsGames project, I will continue to add information to oddities that I’m finding that will hopefully help out somebody that either was doing as much screaming about the problem as I was, or somebody looking for simpler ways to do what they are trying to do.