Solved

pass object from one mxml to another

Posted on 2011-03-06
4
791 Views
Last Modified: 2012-05-11
hi guys

I have a very simple requirment but dont seem to find an answer on google.

main.mxml  has a button . when button is clicked a pop up displays. From my main.mxml i am passing a arraycollection which i want to display in the pop-up

main.mxml
<mx:script>
private function launchPopUp(e:MouseEvent,projectList:ArrayCollection):void {
var popupwindow : Window = new Window();   
PopUpManager.addPopUp(popupwindow,this,true);
PopUpManager.centerPopUp(popupwindow);
}
</mx:script>

<mx:Button id="button" label="show" click="launchPopUp(event,arrayCollection);"/>  //passing the arrayCollection

Open in new window


and this is Window.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
 width="650"
 height="250"  
itle="PopUp Window" horizontalAlign="center"
showCloseButton="true"	
close="closeWindow(event);" >
<mx:Script>
<![CDATA[
import mx.core.IFlexDisplayObject;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;			
private function closeWindow(e:CloseEvent):void {
PopUpManager.removePopUp(e.target as IFlexDisplayObject);
}
]]>
</mx:Script>
<mx:Image source="assets/img.gif"/>	
<mx:DataGrid id="dataGrid" dataProvider="{arrayCollection}" width="182/>  //trying to get arrayCollection here
<mx:columns>
</mx:columns>
</mx:DataGrid>
	
</mx:TitleWindow>

Open in new window


 how can i get the 'arrayCollection'   in Window.mxml from main.mxml
Is this possible?

thanks for any help
0
Comment
Question by:royjayd
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 35052214
Window.mxml - in the scripts tag add this line:
public var projectList:ArrayCollection;

Open in new window


main.mxml - pass the collection to the popup like this:
<mx:script>
private function launchPopUp(e:MouseEvent,projectList:ArrayCollection):void {
var popupwindow : Window = new Window();   
popupwindow.projectList = projectList;
PopUpManager.addPopUp(popupwindow,this,true);
PopUpManager.centerPopUp(popupwindow);
}
</mx:script>

<mx:Button id="button" label="show" click="launchPopUp(event,arrayCollection);"/>  //passing the arrayCollection

Open in new window


Warm Regards
Deepanjan Das
0
 

Author Comment

by:royjayd
ID: 35052973
hi thanks very much.

Is there anyway i can display the popup on the top-right section of screen.
Right now i have PopUpManager.centerPopUp(popupwindow);  
i removed that but how do i put it on the top-right just above the button?

thanks
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35053366
set the x and y of popupwindow based on its size and stage size.

Warm Regards
Deepanjan Das
0
 

Author Comment

by:royjayd
ID: 35053409
thanks very much for help.

Any help with next question will be greatly appreciated
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_26867115.html

thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now