Sending data to a pop-up window, Chapter 13, Solution 3

­
<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
// Flex Solutions: Essential Techniques for Flex 2 and Flex 3 Developers
// Author: Marco Casario 
// Editor: FriendsOfED www.friendsofed.com
// All Rights Reserved.
//
// Chapter 13: User Navigation in Flex Applications
// 
// Solution 13-3: Sending data to a pop-up window
//
// 
// @author      Marco Casario
// @date        26 November 2007
// @version     1.0
// @site        flexsolutions.comtaste.com
//
////////////////////////////////////////////////////////////////////////////////
-->
 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="vertical" creationComplete="myHS.send();init()">
 
 
	<mx:HTTPService id="myHS" url="data/users.xml"
		result="myAC = myHS.lastResult.users.user as ArrayCollection" 
		showBusyCursor="true"/>
 
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.collections.ArrayCollection;
			import mx.managers.PopUpManager;
 
			import mx.core.IFlexDisplayObject;
			import com.flexsolutions.chapter13.popup.DetailPopUp;
 
			[Bindable]
			private var myAC:ArrayCollection = new ArrayCollection();
 
 
			private function init():void
			{
				myList.addEventListener( MouseEvent.CLICK, clickHandler );
			}
 
			private function clickHandler( event:MouseEvent ):void
			{		
				var myPopUp:IFlexDisplayObject = PopUpManager.createPopUp (this, DetailPopUp, true);
 
				DetailPopUp( myPopUp ).email = List( event.currentTarget ).selectedItem.address;
				DetailPopUp( myPopUp ).firstname = List( event.currentTarget ).selectedItem.firstname;
				DetailPopUp( myPopUp ).lastname = List( event.currentTarget ).selectedItem.lastname;
 
				PopUpManager.centerPopUp( myPopUp );
			}
		]]>
	</mx:Script>	
 
 
	<mx:Label text="Select a name on the List to view more info : " />
	<mx:List id="myList" labelField="firstname"  dataProvider="{myAC}" />
 
</mx:Application>