Flex Framework: Using Mate to populate a datagrid with an ArrayCollection
Recently I have been learning to use and implementing the Mate Event based framework for Flex. I have to say it is very easy to pick up and will definitely be digging into it more as the days come. I am including a sample Flex project as a zip file in this post and won’t get into the fine details…unless I am asked to. In using Mate, one of the most important tips is to know what files to create and the process of using those files. For this demo I will be using the EventMap (of course…), and the Manager class. Below is the order or items needed and what they are used for.
Of course, learn more about Mate and get the framework here.

AS3: Creating custom events
Let’s say you are creating a custom data service provider that can be used by more than one class in your project, or even a portable re-usable class. A nice, clean way to instantiate the data service provider without getting a cart before the horse error (datagrid trying to populate with data that is not yet loaded, etc…), is to use a custom event. It is very easy to create a custom event, dispatch it and listen for it. This way you can have say your datagrid in an mxml file, import the data service provider that has a RemoteObject in it, and the populate the datagrid ONCE the RemoteObject returns data. How would the datagrid know the data is ready?? A custom event!
Below is a simple example of a custom event class, and an mxml file using the custom event. EventPractice.mxml imports the CustomEvent.as file, adds listeners for the custom event while the buttons each dispatch one of the custom events. You simply pass the string value of the CONST variable in the custom event as an argument in the CustomEvent.as constructor, e.g. “dispatchEvent(new CustomEvent(“cEvent01″));”.
AS3: Re-Usable TextFormat class
In this simple tip I provide an easy to use text formatting class. To use this class, simply import the class into your existing document class or other, and then create a variable instance. To call the formatter you will use “textfield.setTextFormat(variable.formatfunction);
The formatting class is below:
package com.riareviver{ //FLASH CLASS IMPORT import flash.display.MovieClip; import flash.events.*; import flash.text.TextFormat; public class TxtFormat extends MovieClip { //VAR public var myTextFormat:TextFormat = new TextFormat(); public function TxtFormat() { //TEXT FORMATTER myTextFormat.font = "Verdana"; myTextFormat.color = 0xFFFFFF; myTextFormat.size = 10; myTextFormat.align = "left"; } } }
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.

Recent Comments
GarthDB on FlashBuilder: SourceMate AS3Signals Template:
Thanks Brian. I appreciate this being here....
kathryn on I have joined litl!:
psyched to have you onboard! this team just gets more and more awesome....
Filippo on My FlashBuilder 4 color scheme.:
Flash Builder is such a powerful tool, but syntax highlighting just sucks! ...
Devi on AS3: Creating custom events:
This example is awesome...
Josh Molina on AS3: Creating custom events:
Excellent tutorial. Straight and to the point.Thank you.Jo...