Simplest is to have your PopUp call a method on the Main app in the
closeDialog method.  I have an example of this on cflex.net.  But best
practice is probably to have the title window emit an event, and in the
handler, use event.target to get the value you want.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of jmfillman
Sent: Friday, March 02, 2007 3:55 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing data from TitleWindow to application

 

I've attempted to model this after an Adobe example found here: 

http://livedocs.adobe.com/flex/201/html/textcontrols_060_19.html
<http://livedocs.adobe.com/flex/201/html/textcontrols_060_19.html> 

I'm trying to take that example and apply it to set the height of a 
control, based on logic in the TitleWindow popup. When you close the 
TitleWindow, I want the height value of the List to be updated.

FILE: test.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
layout="absolute" creationComplete="initApp()">

<mx:Script>
<![CDATA[
import mx.controls.TileList;
import mx.controls.Button;
import mx.controls.Alert;
import mx.events.DragEvent;
import mx.controls.List;
import mx.managers.DragManager;
import mx.core.DragSource; 
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;

public var w:IFlexDisplayObject; 

private function initApp():void {
var dp:Array = ([
{label:"First", data:"25"},
{label:"Second", data:"50"},
]);
listOne.dataProvider = dp;
box001A.dataProvider = [];
}

public function slotDetails(slot:TileList):void {
var w:MyTitleWindow = MyTitleWindow
(PopUpManager.createPopUp
(this, MyTitleWindow, true));
w.height=200;
w.width=340;
w.slotHeight = slot.height;
PopUpManager.centerPopUp(w);
} 

]]>
</mx:Script>

<mx:List id="listOne" dragEnabled="true" 
dropEnabled="false" x="10" y="10"></mx:List>
<mx:TileList x="10" y="172" dropEnabled="true" 
dragMoveEnabled="true" dragDrop="slotDetails(box001A)" 
dragEnabled="true" id="box001A" rowCount="1" columnCount="1" 
height="25" width="162">

</mx:TileList>
<mx:Text x="10" y="289" text="{box001A.height}" 
width="82"/>


</mx:Application>

FILE: MyTitleWindow.mxml

<?xml version="1.0"?>

<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
title="Details" showCloseButton="true" close="closeDialog();">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.controls.Alert; 

public var slotHeight:Number;

public function closeDialog():void {
var sizeNum:Number = 0;
sizeNum = slotSize.value * 2.5;
slotHeight = sizeNum;
PopUpManager.removePopUp(this);
}

]]>
</mx:Script>

<mx:Label text="Size"/>
<mx:NumericStepper id="slotSize" maximum="1440" minimum="10"/>
<mx:Button label="Done" click="closeDialog()"/>

</mx:TitleWindow>

 

Reply via email to