A few notes on flex objects

For a java developer starting to work with flex seems quite easy. However since most people will never read the hole manuals, probably also because of this easiness I’ve decided to write some things about flex objects which are not immediately obvious from a java developer point of view.

The flex objects are hashes

This is the most interesting aspect of a flex Object from my point of view and if you see things in this way then the following might seem a bit more clear:

Creating an object:

var myObj:Object = {'keyA':'valueA','keyB':'valueB'}


var myObj:Object = {keyA:'valueA',keyB:'valueB'}

Notice that in the second case keyA and keyB are not quoted so they do not seem strings at all but as far as I understand they are still string keys. But this leads us to the following:

You can easy access a property by name

This is some kind of reflection from a java perspective but assuming you have a property named myProp in your object you can always access it by a string name. The following is true:

myObj['myProp'] = myObj.myProp

You can easy iterate objects

for(var k:Object in o){
     trace('key: ' + k + ', value:' + o[k]);


for each(var v:Object in o){
     trace(value:' + v);

Find more advanced informations by reading about ObjectUtil or in adobe full documentation.

Leave a Reply