I need to bind a property to an edit control, and the control will return its value to the same property. The problem is that I set the initial value before creating the control:
<mx:Panel> <mx:Script> <![CDATA[ [Bindable] public var editedDocument: XML; ]]> </mx:Script> <mx:TextInput id="docLabel" text="{ editedDocument.@label }"/> <mx:Binding source="docLabel.text" destination=" editedDocument.@label "/> </mx:Panel>
I call it this:
var xmlDoc: XML = <document label="some label" />; var myPanel: MyPanel = new MyPanel(); myPanel.editedDocument = xmlDoc; parent.addChild(myPanel);
What's happening:
- docLabel text field ends with a blank (equal to "")
- XmlDoc @label attribute has a value of ""
I want this:
- docLabel text field must contain "some label"
- the xmlDoc @label attribute should only change when the docLabel text property changes.
How to do this using Flex 3?
Edit
I also tried this:
<mx:Panel> <mx:Script> <![CDATA[ [Bindable] public var editedDocument: XML; ]]> </mx:Script> <mx:TextInput id="docLabel"/> <mx:Binding source=" editedDocument.@label " destination="docLabel.text"/> <mx:Binding source="docLabel.text" destination=" editedDocument.@label "/> </mx:Panel>
The result is the same.
source share