Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: popup question  (Read 8757 times)
vladakg85
Full Member
***
Posts: 22


View Profile Email
« on: July 02, 2009, 01:10:19 »

How to register mediator for popup? I dont know what parameter to pass in:
:
facade.registerMediator(new DetailsPopupMediaotr(???));

I use the following popup class, I wonder is this one http://www.nutrixinteractive.com/blog/?p=329 better, somehow?

:
package util.popup
{
import flash.display.DisplayObject;
import flash.display.Sprite;

import mx.core.Application;
import mx.core.IFlexDisplayObject;
import mx.managers.PopUpManager;

import org.puremvc.as3.multicore.patterns.facade.Facade;

/**
* Used to handle popup opening controling registering and unregistering mediators
*
* @author
*/

public class PopManager extends PopUpManager
{
private static var popupList:Array=new Array();

/**
* Opens a popup window. Window component is crated and mediator is assigned to it.
* Targeted for PureMVC multicore so method requires moduleId to be passed
*/
public static function openPopUpWindow(ComponentClass:Class, MediatorClass:Class, moduleUid:String, modal:Boolean=true, parent:DisplayObject=null):IFlexDisplayObject
{
if (parent == null)
{
parent=Application.application as DisplayObject;
}
var window:IFlexDisplayObject=PopUpManager.createPopUp(parent, ComponentClass, modal);
var obj:Facade=Facade.getInstance(moduleUid)as Facade;

obj.registerMediator(new MediatorClass(window));
PopUpManager.centerPopUp(window);
return window;
}

/**
*  Removes PopUp window and unregisteres associated mediator
*/
public static function closePopUpWindow(window:IFlexDisplayObject, mediatorName:String, moduleUid:String):void
{
PopUpManager.removePopUp(window);
Facade.getInstance(moduleUid).removeMediator(mediatorName);
}

/**
*
* Tries to retrieve popup window from the list of popups already opened. If there is no window opened with
* provided mediator name associated with it, a new one is created and displayed.
*/
public static function retrievePopUp(ComponentClass:Class, MediatorClass:Class, mediatorName:String, moduleUid:String, modal:Boolean=true):IFlexDisplayObject
{
if (popupList[mediatorName])
{
PopUpManager.addPopUp(popupList[mediatorName]as IFlexDisplayObject, Application.application as Sprite, modal);
PopUpManager.bringToFront(popupList[mediatorName]);
}
else
{
popupList[mediatorName]=openPopUpWindow(ComponentClass, MediatorClass, moduleUid, modal)
}
return popupList[mediatorName];
}

/**
*  Removes popup from display list. The actual popup object still exists in the list and can be retrieved
*/
public static function hidePopUp(window:IFlexDisplayObject, mediatorName:String):void
{
PopUpManager.removePopUp(window);
}

/**
* Removes the popup completle. Also unregisters mediator.
*/
public static function destroyPopUp(window:IFlexDisplayObject, mediatorName:String, moduleUid:String):void
{
closePopUpWindow(window, mediatorName, moduleUid);

if (popupList[mediatorName])
{
popupList[mediatorName]=null;
}
}
}


}
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 02, 2009, 03:16:57 »

You can create the popup component and then pass it to its mediator constructor, or you can have the mediator take no argument and create the popup itself in its constructor.


-=Cliff>
Logged
xAvIxXxXx
Newbie
*
Posts: 4


View Profile Email
« Reply #2 on: July 15, 2009, 07:51:03 »

You use the Multicore or the standard version ?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: July 15, 2009, 09:46:18 »

Me? MultiCore, even if I only have one Core. This lets me break it into a modular app quickly and easily at anytime. And unit testing things is easier since you can get a new facade for each test, and don't have to do much teardown/setup.

-=Cliff>
Logged
xAvIxXxXx
Newbie
*
Posts: 4


View Profile Email
« Reply #4 on: July 22, 2009, 08:06:35 »

It was to understand the post but your answer is interesting and I have understand vladak problem now.
In my view the class (PopManager) is very useful because it is generic and well adapted to the multicore.
Logged
Pages: [1]
Print