AS3 Playground: Multiple dynamic moveable panels
This tip will show you how to 1. create movable panels, and 2. to create them using array and for loop statements to access the panel class. This is an exercise in creating re-usable code classes, and accessing them with and array.
First we create a Flash project to hold all the files for the exercise. Then we create 3 separate files, one .fla and two .as files. The .fla does nothing more than access the document class and set the size of the stage. I usually name the document class the same as the .fla, but feel free to name it as you like. The two .as classes that we will create are the one we will use as the document class (PanelNav.as) and a class that holds the panel creation code (PanelSpawn.as).
The class PanelNav.as imports the class Panel Spawn.as, creating panels by cycling through an array of information. I am passing a few arguments from the array, but more can be passes as you get into the class, such as header color, border color, etc. Everything is generated by using one major for/loop statement, cycling through the amount of Array items, generating a panel from the PanelSpawn.as class for each array item. You can use the PanelSpawn.as class to create one panel, but why when you can create an unlimited amount of panels by using a simple array and for statement? Enough of my explanation, here is the code.
Download the source project here
Click and drag a panel below, note the transparency on click.
AS3 Playground: Simple Particles
First off, I will say that without Matthew Tretter’s garbage collection classes this demo would not be easy…While generating this many “particles” on ENTER_FRAME, the Flash Player can not keep up (or wouldn’t in my case), with the 3 tweens on X, Y, and alpha.
After saying that…here is a demo that I came up with tonight playing around in Flash and practicing some rapid development prototyping. It is a “particle” generator (that’s what I am calling it) using the display class, randomly positioning X and Y, as well as tweening the alpha channel.
Keep in mind this is simply a playground exercise and not necessarily, or really at all, optimized for memory.

Go ahead, click and drag below…you know you want to.
AS3 Playground: Alternate row colors on dynamic MovieClips
Below is an example of how to dynamically change the row color of generated movieclips. I find this helpfu when making grid based layouts, buttons, etc. You can have an unlimited amount of row colors by adding to the two if/then statements. Also, you can make this class re-usable by simply adding variables in the public function, passing them into the constructor method from your main fla movieclip instantiation. I try to keep all variables outside the main constructor, or at least in a single area, to help maintain the code and keep it cleaner.
Download the source project here

AS3 Playground: Floating Tool Tip using currentTarget
Without a lot of explanation on the topic, the following package creates 4 squares dynamically, then uses event listeners to point to global methods that checks the currentTarget. Based on mouse over or mouse out a method is called to show the tool tip (created on the fly) and changes its X and Y based on your mouse location. Basically, it is a floating tooltip demo, showing you how helpful currentTarget is.



Recent Comments
connatser on AS3 Playground: Simple Particles:
thanks Richard, and thanks for checking it out!...
connatser on AS3: Motion Blurring with Flash, part 1:
I agree, thanks. I will get some source files together and update the post....
Chris on AS3: Motion Blurring with Flash, part 1:
would be a lot easier to follow this tute for a beginner if you'd inclu...
rv on AS3 Playground: Simple Particles:
great example, nice job....
ericfickes on 360Flex: Stoked to get a break and hear great devs.:
Hey Brian, be sure to say hi at 360. Jun and I are pretty excited about th...