Circular Rotation and Orbiting in AS3

Once again, the OOP support in AS3 makes for simplifying some previously complicated effects down to a simple implementation. In this post, I want to give an overview of something that nearly anyone who ever deals in manual animation will need to figure out: circular rotation and/or orbiting around another object. To assist in this, I have created an extremely simple orbiter class that will take a few arguments to define its behavior along with a target (or origin) around which to orbit. I have written this in such a way as to accept any Object as an origin, so this will allow us to assign an Orbiter object to rotate around anything in our SWF.

Now, as many people are not only apprehensive about math when dealing in Flash but also attempt to avoid it entirely. That is one of the reasons I tried to consolidate the orbiting pattern into a simple object: it allows for us to deal with one single algorithm that can be found all over the internet and implement it to nested objects to create some pretty complex orbital patterns. Of course, since we are dealing with circular patterns, this isn’t the appropriate method to approach the issue of true planetary or elliptical orbits, but for effects and basic visuals, it works quite well. The Orbiter object is not intended to be a solution in and of itself, but rather it is intended to be a base class upon which you can build specific rotational objects with their own visuals and effects.
Continue reading