Solved

Popup Window in Flex that returns data and that can be passed parameters

Posted on 2011-03-24
2
1,016 Views
Last Modified: 2012-06-27
Hi everyone,

How do you create a popup window in flex that can take parameters and return values?
I would like to place flex components in the popup window and whatever else so it can be part of the application....

So far I have:

private function launchPopUp():void {
				var win : DocumentViewer = new DocumentViewer();
				//win.xmlDisplay.text = "sent text to this popup!!";
				
				//win.setText("this would be text");
				
				//win.txt.text = ".............................";
				PopUpManager.addPopUp(this,win,true) as DocumentViewer;
				PopUpManager.centerPopUp(win);
				
		}

Open in new window


Thanks!
0
Comment
Question by:ronyosi
[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 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 35208764
I will suggest to create a new component

DocumentViewer.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
				xmlns:s="library://ns.adobe.com/flex/spark" 
				xmlns:mx="library://ns.adobe.com/flex/mx" 
				layout="vertical" width="400" height="300"
				showCloseButton="true" close="closeWindow(event)">
	<fx:Script>
		<![CDATA[
			import mx.core.FlexGlobals;
			import mx.managers.PopUpManager;

			protected static var _window:DocumentViewer;
	
			public var callBackFunction:Function;
	
			public static function openWindow(defaultValue:String=null, callBack:Function=null):DocumentViewer{
				if(_window == null){
					_window = PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, DocumentViewer, true) as DocumentViewer;
					_window.callBackFunction = callBack;
					_window.xmlDisplay.text = defaultValue;
				}
				PopUpManager.centerPopUp(_window);
				return _window;
			}
	
			protected function closeWindow(event:Event=null):void{
				if(callBackFunction != null)
					callBackFunction(this);
				PopUpManager.removePopUp(_window);
				_window = null;
			}
		]]>
	</fx:Script>
	<s:TextArea id="xmlDisplay"/>
</mx:TitleWindow>

Open in new window


And you can call from anywhere

function callBackHandler(win:DocumentViewer):void{
		trace(win.xmlDisplay.text);
	};
	var window:DocumentViewer = DocumentViewer.openWindow("Default Value", callBackHandler);
	window.xmlDisplay.text = "Override Default value";

Open in new window

0
 

Author Closing Comment

by:ronyosi
ID: 35344531
Thanks :)
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 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