I have a List with textInput as itemrenderer. Initially the list is loaded with data from a data provider. However since the items are rendered in textInputs, I have the ability to change the value of a particular item.
But when trying to access the value of the changed item using the function below, I still get the old value in my trace:
private function addItem(event:Event):void {
trace(myDataProvider.getItemAt(myList.selectedIndex).label);
}
can someone tell me what I need to do for the new value to be available. My itemrenderer is shown below:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="components.*"
>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:S开发者_Python百科cript>
<![CDATA[
override public function set data( value:Object ) : void {
super.data = value;
}
protected function myTextInput_enterHandler(event:FlexEvent):void
{
trace(myTextInput.text);
What Next??
}
]]>
</fx:Script>
<components:myComp1 text="{data.label}" id="myTextInput" enter="myTextInput_enterHandler(event)"/>
</s:ItemRenderer>
Thanks for your help..anyone.
Try to use:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="components.*"
>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
override public function set data( value:Object ) : void {
super.data = value;
}
protected function myTextInput_enterHandler(event:FlexEvent):void
{
trace(myTextInput.text);
data.label = myTextInput.text;
}
]]>
</fx:Script>
<components:myComp1 text="{data.label}" id="myTextInput" enter="myTextInput_enterHandler(event)"/>
</s:ItemRenderer>
精彩评论