I have a quesion about how to access main window’s variable from popup window.
I create a popup window in the main window, and pass variable “content” to this popup window as following code:
<mx:Script>
<![CDATA[
// ......
popwin = PopUpManager.createPopUp(UIComponent(parentApplication), PopupWindow, true) as PopupWindow;
popwin.parentView = this; // parentView is an IFlexDisplayObject
popwin.content = content;
PopUpManager.centerPopUp(popwin);
// ......
]]>
</mx:Script>
In the popwin, I changed value of “content” variable, but I want reset the value of “content” when click “Reset” button on popwin.
I know, I dispatch an event in popwin window, and add listener in main window
Code fragment in popwin:
parentView.dispatchEvent( new CustomEvent(CustomEvent.RESET) );
Code fragment in main window:
addEventListener(CustomEvent.RESET, resetContent);
public function resetContent():void{
this.content = loadContent();
}
But the value of “content” doesn’t reset in popwin.
Is there anything I missed?
Is there any other method to update “content” in popup window?
=====================Question update at 15/8/2011==============================
I use following code in popwin’s createComplete() function:
BindingUtils.bindProperty(textInput, "text", content, "name", false);
When I change the text value of textInput and reset the content, it load original value of content.name in my trace log, but the text value of textInput doesn’t revert to original value.
If I use following code instead BindingUtils.bindProperty:
[Bindable]
public var content:Content;
......
<mx:TextInput id="textInput" text="{content.name}" />
And do the same action, the content.name is reload in my trace log, but the text value set to blank in textInput.
Is anyone know why?
Try to use: