Since this gets asked very often, I have created a full sample, listing below, that uses three different ways to pass data into a title window.
It uses the initobj to pass in several built-in properties plus two user defined properties. One is a simple string, the other is a reference to the main application that can be used for binding. Note the variable that holds the application reference is typed to the name of the application. this is critical for binding to work correctly. It also uses the reference to the created pop-up to set a variable in the title window from the main app. Tracy ***TitleWindowData.mxml*** <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.macromedia.com/2003/mxml" closeButton="true" click="this.deletePopUp();" creationComplete="initComponent()"> <mx:Script><![CDATA[ public var mainApp:TitleWindowDataTest = null; //will be populated by passed in initobj public var gsMyString:String; //will be populated by passed in object public var gnMyNumber:Number; //will be populated by reference in main app private function initComponent():Void { lblCalc.text = (9 * gnMyNumber); } ]]></mx:Script> <mx:HBox > <mx:Label text="{gsMyString}" width="150" /> <mx:Label text="Bound to local variable populated by initobj argument" /> </mx:HBox> <mx:HBox > <mx:Label id="lblMyNumber" text="{gnMyNumber}" width="150"/> <mx:Label text="Bound to local variable populated by reference in main app" /> </mx:HBox> <mx:HBox > <mx:Label text="{mainApp.gsBindMe}" width="150"/> <mx:Label text="Bound to main app variable via passed in reference" /> </mx:HBox> <mx:HBox > <mx:Label id="lblCalc" width="150"/> <mx:Label text="Calculated value set by initialize event handler" /> </mx:HBox> </mx:TitleWindow> ***TitleWindowDataTest.mxml*** <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" horizontalAlign="left"> <mx:Script><![CDATA[ public var gsBindMe:String = "Change me!" ; // import mx.containers.TitleWindow; import mx.managers.PopUpManager; private function showTitleWindow():Void { var oInitObj:Object = new Object(); oInitObj.title = "Title Window Data"; //built-in property oInitObj.width = 600; //built-in property oInitObj.height = 200; //built-in property oInitObj.mainApp = this; //user-added property. reference to main app oInitObj.gsMyString = tiMyString.text; //user-added property. will contain value of text input var titleWindowInstance:Object = TitleWindow(PopUpManager.createPopUp(this, TitleWindowData, false, oInitObj, false)); //instantiate and show the title window titleWindowInstance.centerPopUp(this) titleWindowInstance.gnMyNumber = parseFloat(tiMyNumber.text); //titleWindowInstance must be Object to use this } ]]></mx:Script> <mx:HBox > <mx:Label text="MyString:" width="100" /> <mx:TextInput id="tiMyString" text="my string" /> </mx:HBox> <mx:HBox > <mx:Label text="MyNumber:" width="100"/> <mx:TextInput id="tiMyNumber" text="99"/> </mx:HBox> <mx:HBox > <mx:Label text="Bind Me" width="100"/> <mx:TextInput id="tiBindMe" text="{gsBindMe}" change="gsBindMe = tiBindMe.text"/> </mx:HBox> <mx:Button label="ShowTitleWindow{newline}Non-Modal" click="showTitleWindow()"/> </mx:Application> -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Francesco Sent: Thursday, June 02, 2005 11:10 AM To: Flexcoders Subject: [flexcoders] Passing parameter from panel to popupwindow Hi, I've a question about passing parameter. The problem: I have a panel with a button. (popupwindowdemo.mxml) When I press the button a popup window will be opened (the definition of the window stay in another file logonwindowdemo.mxml) My question is: How can I pass a parameter (String) from the panel to the popup windows (pressing the button) ? In my case I'd like that the field "userid" will be automatically completed... Thanks Francesco Here is the code (from explorer) /****************************/ popupwindowdemo.mxml /****************************/ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> <mx:Script> function showWindow(modal) { var popup = mx.managers.PopUpManager.createPopUp(_root, LogonWindow, modal, {deferred: true}); } </mx:Script> <mx:Button label="Show Window" click="showWindow(false)" width="150"/> <mx:Button label="Show Modal Window" click="showWindow(true)" width="150"/> </mx:Application> /*****************************/ logonwindowdemo.mxml /*****************************/ <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.macromedia.com/2003/mxml" title="Logon"> <mx:Form> <mx:FormItem label="UserId" required="true"> <mx:TextInput id="userId" width="150"/> </mx:FormItem> <mx:FormItem label="Password" required="true"> <mx:TextInput id="password" width="150"/> </mx:FormItem> <mx:FormItem> <mx:HBox horizontalGap="30"> <mx:Button label="Logon"/> <mx:Button label="Cancel" click="this.deletePopUp()"/> </mx:HBox> </mx:FormItem> </mx:Form> </mx:TitleWindow> Yahoo! Groups Links Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
TitleWindowDataTest.mxml
Description: TitleWindowDataTest.mxml
TitleWindowData.mxml
Description: TitleWindowData.mxml

