Solved

pass object from one mxml to another

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

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…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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