I am a frontend developer and author based in the UK, specializing in JavaScript development and application architecture. I founded Newtriks Ltd. and have been remotely contracting for the last 10 years for global corporations and venture-backed start-ups. I regularly consult Angular, Backbone, and React, and train programmers in test-driven development. I'm an enthusiastic open source contributor and am the cofounder and lead developer of the live webcasting platform Sayansho Ltd. Please contact me to discuss your specific business requirements.
Handling Popup Logic in PureMVC *Update*
I have since re-structured some of my logic in handling popups in a Flex application using PureMVC. If you refer to my previous post you will see that I have a PopManager that extends PopUpManager and the core logic to handle opening and closing Popups was via the Mediator. I have now ripped this logic out so it is handled by a Command and popups can now be opened/closed via a notification, cleaner, simpler and more logical to PureMVC.
Here is a summary of how to handle popups more efficiently enabling multiple popup window types i.e. image popups, form popups etc. note Multicore SWC used:
public class CustomPopMediator extends Mediator implements IMediator
{
public static const NAME:String = 'CustomPopMediator';
private var __popData:PopDataVO;
public function CustomPopMediator( viewComponent:Object )
{
super( NAME, viewComponent );
}
public function set popData( val:PopDataVO ):void
{
__popData = val;
}
override public function onRegister():void
{
pop.addEventListener( CustomPopMediator.CLOSE_POP, onClose );
}
protected function onClose( e:Event ):void
{
sendNotification( ApplicationFacade.HANDLE_POP, ResourceConstants.CUSTOM_POP, ResourceConstants.CLOSE_POP );
}
protected function get pop():CustomPop
{
return viewComponent as CustomPop;
}
}
PopDataVO
12345678
public class PopDataVO
{
public var type:String;
public var title:String;
public var body:Object;
public function PopDataVO(){}
}
PopInstanceVO
12345678910
public class PopInstanceVO
{
public var window:IFlexDisplayObject;
public var mediator:String;
public var name:String;
public var x:Number;
public var y:Number;
public function PopInstanceVO(){}
}
CustomPop is simply an mxml component extending TitleWindow.
You can now call out CustomPop like so:
12345
var pObj:PopDataVO = new PopDataVO();
pObj.type = ResourceConstants.CUSTOM_POP;
pObj.body = "newtriks.com";
sendNotification( ApplicationFacade.HANDLE_POP, pObj, ResourceConstants.OPEN_POP );