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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Getting Started / Pop up registering in a multicore version on: July 15, 2009, 07:58:39
Hi,

I have a problem of registering a popup in the multicore version.
The launching of the popup is done in a Module, but there are a lot of components contained in the module and it is not very clean to access the Module (to retrieve the moduleID) with the parent.parent...

I would like to use the popup class showed under but I don't know how to retrieve the moduleUid.
Does anyone know how to do that ?

Thanks in advance.
Xavi

:
package com....
{
    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 created 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;
            }
        }
    }

}
Pages: [1]