Solved

pass object from one mxml to another

Posted on 2011-03-06
4
787 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

12 Experts available now in Live!

Get 1:1 Help Now