I saw this "trick" in someone's code and have been using it lately so I thought I'd share. The idea is to create an object, bind it to the form elements, and bind the form elements to the object. In this example, I'm using a simple form from an app I'm working at the moment.
Userform.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:dto="com.katapultmedia.mystreamer.dto.*">
<mx:Script>
<![CDATA[
private function save():void{
}
]]>
</mx:Script>
<dto:User id="user" />
<mx:Binding source="firstNameField.text" destination="user.firstName" />
<mx:Binding source="lastNameField.text" destination="user.lastName" />
<mx:Binding source="emailAddressField.text" destination="user.emailAddress" />
<mx:Binding source="passwordField.text" destination="user.password" />
<mx:Binding source="isActiveCheck.text" destination="user.isActive" />
<mx:Form>
<mx:FormItem label="First Name">
<mx:TextInput id="firstNameField" text="{user.firstName}" />
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="lastNameField" text="{user.lastName}" />
</mx:FormItem>
<mx:FormItem label="Email Address">
<mx:TextInput id="emailAddressField" text="{user.emailAddress}" />
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="passwordField" text="{user.password}" />
</mx:FormItem>
<mx:FormItem>
<mx:CheckBox id="isActiveCheck" selected="{user.isActive}" />
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Save" click="save()" />
</mx:FormItem>
</mx:Form>
</mx:VBox>
So, I'm not going to go line but line since it is pretty straight forward but here's a brief outline.
Form Items
- Each TextInput is bound to the user objects respective property (ex - firstNameField.text is bound to {user.firstName}).
- The isActiveCheck is bound to {user.isActive}
Binding Tags
- Each Binding tags source property is bound to one of the form items.
- Each Binding tags destination property is bound to the respective user property.
That's it. What happens is when I create an instance of this component I will set myUserForm.user = someUser; and when the user edits one of the form items the respective value of the user object will be updated instantly. This way, when the user clicks the Save button I can easily pull myUserForm.user and pass that dto (data transfer object) to the backend.
Kinda cool, huh? Well, I think so. Saves a good bit of Actionscript writing.
Enjoy.
Update: I should test code before posting. :-) I've removed the brackets around the source/destination properties on the Binding tags. They aren't needed.
If you are looking for a good piece of software for bug tracking, I highly suggest looking at Axosoft's OnTime. I last used the 2006 version and had numerous issues with it. My biggest issue was licensing. For a small, growing shop, at the time, with contractors coming in and out I didn't want to keep buying licenses for every contractor that wasn't a steady contractor. Without that issue, the desktop and web versions were a bit slow at times.
Well, 2008 has fixed the issue of slowness. It is really fast, in comparison, and still very easy to use/setup. The web version is AMAZINGLY better than '06. It was pretty bad in 06: very slow, not as slick, everything was a refresh (no ajax), etc. I just installed the '08 Web and I'm pleased.
Anyways...I'm not going to give a feature-by-feature review but thought I'd let folks know they might want to take a look.
Watch the videos and you'll get a good feel for several of the great features OnTime provides.
I'm researching OpenAIM for an upcoming article and thought I'd share a few quick tidbits about connecting to OpenAIM. Let me first say...I didn't do anything special here. AOL has provided a pretty quality developer center and they have written the ActionScript 3 code necessary for connecting to the AIM service. As a test I thought I'd try to grab my buddy list and show it in an mx:Tree component.
Disclaimer: This is purely a sample app so the code does not use any best practices or anything...just showing how to use the OpenAIM code.
Sample AIR app:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:wim="com.aol.api.wim.*"
layout="absolute"
applicationComplete="init()">
<mx:Script>
<![CDATA[
import com.aol.api.wim.data.types.SessionState;
import com.aol.api.wim.data.User;
import com.aol.api.wim.data.Group;
import com.aol.api.wim.Session;
import com.aol.api.wim.data.BuddyList;
import com.aol.api.wim.events.BuddyListEvent;
import com.aol.api.wim.events.SessionEvent;
private var aolSession:Session = new Session(stage, "your developer key", "Your Test Client", ".1");
private var aolBuddyList:BuddyList;
private function init():void{
aolSession.addEventListener(SessionEvent.SESSION_STARTING, handleSessionStarting);
aolSession.addEventListener(BuddyListEvent.LIST_RECEIVED, handleBuddyListLoad);
aolSession.signOn("your username", "your password");
}
private function handleSessionStarting(event:SessionEvent):void{
aolSession.requestBuddyList();
}
private function handleBuddyListLoad(event:BuddyListEvent):void{
aolBuddyList = event.buddyList;
updateBuddyList();
}
private function updateBuddyList():void{
var buddyList:XML = <node label="AOL Buddy List" />
var group:XML;
var user:XML;
for each(var item:Group in aolBuddyList.groups){
group = <node />
group.@label = item.label;
for each(var userItem:User in item.users){
if(userItem.state == SessionState.OFFLINE) continue;
user = <node />
user.@label = userItem.aimId;
group.appendChild(user);
}
buddyList.appendChild(group);
}
buddies.dataProvider = buddyList;
}
]]>
</mx:Script>
<mx:Tree id="buddies" width="100%" height="100%" showRoot="false" labelField="@label" />
</mx:WindowedApplication>
So, briefly I'll cover the code (gotta cook dinner in a sec; lol). On Line 4, above, we set the applicationComplete event to call our init() function, lines 19 to 23. In there we add a couple event listeners then call the signOn(..) function of the WIM api. Before we can successfully do this the aolSession variable must be created, which we do on line 15.
Note: You HAVE to get a developer key from AOL in order to test this code.
Once the sign on request is complete we call requestBuddyList(), line 26. When the buddy list is returned we set the aolBuddlyList variable then call updateBuddyList(), line 32. The updateBuddyList() function merely loops over the groups (your buddy groups) and users in each group, updates the buddyList XML local variable, then assigns it to the dataProvider of the buddies Tree component.
For the UI we merely create an instance of mx:Tree and set the labelField to @label, which is what we created in the updateBuddyList() function.
That's it. Run the app and you'll see your buddy list in a window like below:
They have some work to do on the source code but I went from from 0 knowledge to this sample app in 20 or so minutes. Grab the code and check it out.
The long debate is back. So many argue the affirmative and are absolutely crazed over the argument. I'm not going to jump into it this time around. I would LOVE to see Standard offered for free but I won't cry if I have to buy the next upgrade to CF9.
So, my post comes from Ben's dissertation (hehe) he just posted on his blog. I'm turning comments off on this post because I don't want to steal any thunder from Ben's overall reason for posting (research into the discussion for Adobe's planning purposes; or that's what I got from the post).
This is just a little piece of code for using a SMIL file as the source of the FLVPlayback component in Flash. This is AS3 code but it is pretty much the same for AS2.
import fl.video.FLVPlayback;
var player:FLVPlayback = new FLVPlayback();
addChild(player);
player.source = "my.smil";
Join me tonight for my ColdFusion 8 .NET Integration preso on Adobe Connect: http://adobechats.adobe.acrobat.com/azcfugmaycf8dotnet/.
See you there.
Just a quick reminder about my engagements this week:
Tomorrow Night (5/27/2008) I'm speaking at the Phoenix ColdFusion Users Group meeting.
Saturday (5/31/2007) I'm speaking at the Desert Code Camp conference here in Phoenix. The sessions are Adobe AIR Offline with LiveCycle Data Services ES 2.6, ColdFusion 8 .NET Integration, and 1 code library, 2 apps.
Hope to see you there.
It is pretty early for them to be out but nonetheless...GET'EM WHILE THEY'RE HOT! :-)
DW CS4 has numerous upgrades/updates to it that have highly impressed me. Still a good amount to do, IMO, but it is looking good.
You can see my mugshot on the Contributor's page of InsideRIA.com. My latest article will be published sometime in the next month or so. I look forward to writing more for InsideRIA. Rich is a cool dude and an easy editor to work with.
Just an FYI for now. More to come when the article publishes.
A lot of folks have been asking for the specifics so I figured tonight is as good as any to explain my move back to Katapult. Keep reading for the big picture.

