i’d set up a repeater to display data returned from a ColdFusion call – which would either be a Y or N. I wanted to adjust how this appears to YES or NO, and thought a straightforward way of doing this would be set up an associative array:

public static var yesNoTranslator:Object={N: "No",Y: "Yes"};

and my text component would look something like:


Flex Builder produced warnings on this, however:
“Data binding will not be able to detect changes when using square bracket operator. For Array, please use ArrayCollection.getItemAt() instead.”

Though in this case, i could ignore the warning and the app would work as desired, i could see that sometimes you may want your associative array to change and the binding wouldn’t detect changes. Anyway, warnings are annoying to have hanging around, and for some strange reason they seem to propogate themselves in Flex Builder…

As the warning describes, if yesNoTranslator was an array, i could use ArrayCollection.getItemAt() instead. yesNoTranslator was an object and there is no equivalent with objects(for some reason), so i thought the simplest thing to do would be to create one, which i’ve called ObjectCollection:

import mx.utils.ObjectProxy;

public class ObjectCollection extends ObjectProxy
public function ObjectCollection(item:Object=null, uid:String=null, proxyDepth:int=-1)
super(item, uid, proxyDepth);
public function getItemAt(index:String):Object {

and modify my above code to:

public var yesNoTranslator:ObjectCollection=new ObjectCollection({Y:"Yes",N:"No"});

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with: ,
Posted in Flex

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: