please use ArrayCollection.getItemAt() instead

I’m doing some binding in flex 2.0, and what i’m trying to do is bind a text area to a field that i return from a query with a remoteObject.

<mx:RemoteObject id=“remoteObj”

destination=“ColdFusion”

source=“some_project.somecfc”

fault=“Alert.show(event.fault.faultString,’Error’);”

>

<mx:method

name=“getConcernOriginal”

result=“concernOriginalReceived(event)”

/>

</mx:RemoteObject>

You bring the query back as an ArrayCollection, i think i caught on to this from some automatic code generated from the cfc wizard using the RDS Plugin for flex builder 2.0… anyway, here is the code for the actionscript

[Bindable]

private var concernOriginal:ArrayCollection = null;

private function concernOriginalReceived(event:ResultEvent):void {

concernOriginal = new ArrayCollection();

concernOriginal.source = event.result.source;

//trace(ObjectUtil.toString(concernOriginal.source));

trace(ObjectUtil.toString(event.result.source[0].Concern_Detail));

}

If you notice in that last trace statement, i’m returning a column from my query… the column name is “Concern_Detail” (if your trying to trace like this PLEASE REFER TO THE “HOW TO DUMP AN OBJECT IN FLEX 2.0” that i recently posted.)

I can dump this correctly, so i am going to put it into a text box…

<mx:Text text=“{concernOriginal.source[0].Concern_Detail}”/>

This works fantastically, but i get this error in my Problems Panel in flex.

“Data binding will not be able to detect changes when using square bracket operator. For Array, please use ArrayCollection.getItemAt() instead.”

New Syntax for the fix

<mx:Text

text=“{concernOriginal.getItemAt(0).Concern_Detail}”

/>

I still get the following in my consol panel when i am debugging though… i’m not sure what this means…

“warning: unable to bind to property ‘Concern_Detail’ on class ‘Object’ (class is not an IEventDispatcher)”

Contact me at:axel@cfwebtools.com if you have any questions

Leave a comment