Main Screen
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, .5]" backgroundGradientColors="[#000000, #000000]" xmlns:ns1="components.*">
Screen Objects
<mx:ComboBox x="68" y="83" id="color_cmb" width="178" dataProvider="{colorsAC}"
editable="false" prompt="Select a Color" change="showPopUpButton.enabled='true'"/>
<mx:Button x="321" y="83" label="Show Next Screen" id="showPopUpButton" click="showThePopUpComponent(color_cmb.selectedItem.label)" enabled="false"/>
<mx:Script>
<![CDATA[
import mx.collections.*; // imports the array classes
import mx.managers.PopUpManager; // imports the PopUpManager
import components.NextWindow; // imports the Next Window component
public var colorsAC:ArrayCollection = new ArrayCollection( [ {label:"Red"}, {label:"Blue"}, {label:"Yellow"}, {label:"Green"}, {label:"Purple"}, {label:"Orange"} ]);
/* This function displays the new window and passed data to it in two ways. 1) Sets a public attribute defined in the window (this attribute is bound to textField2
2) Calls a function in the window (named passData) and passes it the value of the combobox as a parameter. Either way works fine. Which to use would depend on what you are going to do with the data once it gets there */
public function showThePopUpComponent(passedValue:String):void {
var newPopUp:NextWindow = NextWindow(PopUpManager.createPopUp(this, NextWindow, true));
newPopUp.theDataFromTheComboBox = passedValue newPopUp.passData(passedValue); PopUpManager.centerPopUp(newPopUp);
]]>
</mx:Script>
</mx:Application>
Next Window Component
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" title="Next Window with Data Passed From The Combo Box" showCloseButton="true" close="PopUpManager.removePopUp(this)" >
Screen Objects
<mx:Label x="31" y="23" text="No Value Yet" id="textField1"/>
<mx:Label x="31" y="77" text="{theDataFromTheComboBox}" id="textField2" /> <mx:Script>
<![CDATA[
import mx.controls.Alert;
// Allows us to display alert boxes
import mx.managers.PopUpManager;
// Allows us to use PopUpManager Functions (like remove window)
// This variable is bound to textField2. When the main screen puts a value in it, textField2 is automatically updated (cause of dataprovider)
[Bindable]
public var theDataFromTheComboBox:String;
// This function is called from main screen to put data into a text field
public function passData(passedData:String):void { textField1.text = passedData } ]]> </mx:Script> </mx:TitleWindow>