Atom Swing 2
In this piece, I'm playing with a few different things at once.
Imagine a sign, tacked to a fence at four corners. What if all but one tack came loose. The sign would then swing down from that pivot corner. In real life, the sign would swing back and forth until it ran out of momentum. In this piece, however, I'm keeping the model really simple and just rotating the square (on a pivot point) until it hangs straight down. Once the corner diagonal to the pivot corner is pointing down, the square is ready to drop.
The Cell class in this piece assigns a random corner (to be the pivot point) and then draws and positions the graphics based on the corner's offset, before passing it through targetParent.addChild(thisCell). Rotation direction is also based on this corner position. This is all to get around the current problem, of not being able to reset the registration point of a movie clip at run time.
Usually, when I'm moving a bunch of particles around, I store references to them in an array. Animation of these particles is run from an external function and timer, cycling through the array and moving all of the particles one increment per interval.
In this piece, I decided to code the timer/animation internal to the particle class. So, each cell instance has it's own timer object.
The timer object in the box class, controls when a cell's timer is started. I am also storing reference to the particles (cells), external to the particles themselves, but I'm using it to start their independent animation functions.
Using AS3 without a document class or attaching code to symbols in the library.
I'm just playing around here, with another way to structure a project. Instead of using a document class, I'm creating an instance of my Box class and passing it the instance name of a symbol I've drawn on the stage (the big black square).
A link to download source files is near the bottom of this page.