Posted by Jacob Wright in FlexJan 10th, 2008 | 2 Comments
I decided to write on a beginner topic today, so if you know everything there is to know about binding then you may want to pass.
When writing a Flex application I always write “model” objects which represent the data and business logic of my application. These would be the User objects, the ShoppingCart object, or the Document objects (see MVC). The MXML components will bind to these object’s data, and as such, I need to make sure that they will dispatch the correct events for binding to occur.
There are really two main practices to keep in mind. The first is to put the [Bindable]...
Posted by Jacob Wright in AIR, FlexJan 7th, 2008 | 13 Comments
NativeMenus for AIR have been somewhat of a pain since each item in a menu can take 3-4 lines of code or more to write once you add the listener, the key shortcuts, etc. Then when you've got 20 items or so you have an unreadable unmanageable mess to deal with. Very unFlexy. So I set about making it work in MXML with the advantages of readability, conciseness, and don't forget bindability. This makes it a much cleaner solution than a component which creates a commonly used menu or using XML data providers to define the menus.
First I created a Menu class which extends NativeMenu. Because of the...
Posted by Jacob Wright in ActionScript 3, FlexDec 29th, 2007 | 2 Comments
I guess this week is my week for creating AS3/Flex hacks. I created an XML encoder/decoder that will accept a class-map and create your model from your XML and visa-versa. As part of that I have display objects as part of the model that needs saving out. I suppose you could liken it to MXML.
In order for the XML encoder to work with DisplayObjectContainers I had to give it a way to work with an ArrayCollection to add or remove the children. So I subclassed LayoutContainer and gave it a property called "children" which is an ArrayCollection. Then I set up as a listener to it and every time something...
Posted by Jacob Wright in ActionScript 3, FlexDec 28th, 2007 | 1 Comment
I am loving the E4X stuff in ActionScript 3. Once you get your mind wrapped around it and if you don't have to deal with namespaces it is very nice. Namespaces can be useful too, I just wish you could turn a namespace-agnostic-mode on and off.
I just discovered a cool trick I thought I'd share with you. I found it when I was iterating through the properties of two objects to test if they were equal. The properties of one object were all Strings because it was parsed from a comma-delimited file. So, some Booleans or Numbers were strings of "true" or "10.5" while their counter-parts I was testing...
Posted by Jacob Wright in AIR, ActionScript 3, FlexDec 19th, 2007 | 17 Comments
I've been working with AIR quite a bit since my side project is in AIR. I thought it would be pretty cool to create an active record implementation in AIR since I've got one on the server side.
I have to use synchronous database connections for it so that everytime I access an object's related properties I don't have to use a callback, though it could be refactored to do that. Not my idea of fun though, and after an excellent presentation by Jason Williams, "Working with Persistent Data in AIR," where he showed how fast it was to retrieve data from an AIR database I figured it would be just fine.
Currently...
Posted by Jacob Wright in ActionScript 3, FlexJun 26th, 2007 | 23 Comments
So I've been working heavily in Flex lately (and AIR). Been making my own components and building user interfaces for Cascade. For a project I'm working on at work it implements its own localization. It uses a method called getString('myString') to load a string up from the XML strings file.
This was not good for interfaces with lots of strings in it. It required giving every label, every input, every button and id and then after the strings were loaded assigning them all. One of the MXML files I was looking at had over 50 strings to be set and the listener to the string loading ended up being...