Hi everyone,
I
saw in the documentation that one can't bind to elements of an arrays.
Indeed,
it seems that something like <label text={someArray[1]}/> does
nothing.
I
searched through the mailing list archive and made some tests myself, but
couldn't find
something
really simple.
-
The first step seems to put :
"someArray.replaceItemAt(1, item)" instead
of "someArray[1] = item"
The reason is that it will make someArray dispatch a
"modelChanged" event.
-
I tried several things, including using mx:Model or mx:Binding tags to make the
linkage,
but
then I doesn't work, and I couldn't find anyhting better than :
"someArray.addEventListener("modelChanged",
this);"
With
an event handling function that does the binding.
Although
it is working, it looks a bit dirty. I hope there is some way to do it without
any actionscript lines,
just
like the other bindings.
-
Here is a little example of something that I took as a starting example. What
can be done to make it work ?
<mx:Script>
<![CDATA[
var sourceArray = [ "one", "two",
"three" ];
]]>
</mx:Script>
<mx:TextInput id="sourceText"
text="Replace It ! "/>
<mx:Button label="Update data"
click="sourceArray.replaceItemAt(1, sourceText.text);"
/>
<mx:Label text="sourceArray.getItemAt(1)='{
sourceArray.getItemAt(1) }'" />
Thanks,
Damien