Solved

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

Posted on 2011-03-24
2
1,001 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
2 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
Comment Utility
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
Comment Utility
Thanks :)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

14 Experts available now in Live!

Get 1:1 Help Now