Solved

pass object from one mxml to another

Posted on 2011-03-06
4
809 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

615 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