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  PureMVC Manifold / Port Authority / C++ on: May 29, 2008, 07:30:57
Anyone looking at this or interested in?

C++ / STL or some form

2  Announcements and General Discussion / General Discussion / Proxy onRegister Notification - execution order on: May 09, 2008, 10:32:50
Hi All, was doing a few tests (multicore) and noticed some interesting behavior which is related to execution order.

The goal seemed fairly simple, A proxy sends  ApplicationFacade.IM_INITIALIZED, from within its onRegister() but as it appears MODELS done first then VIEWS thus  no "MY DATA IS INITIALIZED" Notification can't be sent from a proxy to a mediator at this startup stage, this can however can be done from a Mediator which would request "INITIALIZE yourself" then the proxy would respond IM_INITIALIZED

notifyObservers: ImInitialized
notifyObservers: StartupInitialized
notifyObservers: Startup

It almost seems like you need a Notification registered in a proxy that gets sent when ALL MODEL/VIEW are registered??
is there a framework suggestion (besides the Mediator call INITIALIZE proxy to get Notification  out)

3  Announcements and General Discussion / Public Demos, Tools and Applications / Notification Chaining Utility on: April 28, 2008, 08:26:59
Hi All,
In an effort to simplify chaining of events within the pureMVC framework, I created a small utility based upon a mediator.
Its purpose is to accept a list of notifications in the order in which you would like them to be processed.
As the Chain Notifier is asynchronous it can be used for transitions or server-side communication, it merely responds to user defined notifications before moving to the next link in its chain keeping things simple and in one place.

In this example the Chain Notifier is within the execution body of a command.
but could be setup where ever you load your mediators.

        override protected function initializeController( ) : void
            registerCommand( STARTUP, StartUpCommand );
            registerCommand( STAGE_INITIALIZED, StageInitializedCommand );

public class  StageInitializedCommand extends SimpleCommand
* Register the Proxies.
override public function execute( note:INotification ) :void
// Register the chainNotifier Mediator and establish chain linkages.
var chainNotifier:ChainNotifier = new ChainNotifier();
chainNotifier.AddNode( ApplicationFacade.SPLASH_SHOW, ApplicationFacade.SPLASH_INITIALIZED, note.getBody() ); //include note for startup
chainNotifier.AddNode( ApplicationFacade.PROGRESSBAR_SHOW, ApplicationFacade.PROGRESSBAR_INITIALIZED);
chainNotifier.AddNode( ApplicationFacade.LOGIN_SHOW, ApplicationFacade.LOGIN_INITIALIZED);
facade.registerMediator( chainNotifier ); //onRegister will start first notification
} ///class
In my example the note.Body was supplied so my splash screen would have a stage VO.
the SPLASH_INITIALIZED notification is what triggers the next link ie: PROGRESSBAR_SHOW and so on.
obviously the last one LOGIN_INITIALIZED does not have anthing to trigger and so is a little superfluous.. :-)

SplashCanvasMediator using chain notification
override public function handleNotification( note:INotification ):void
var stageVO:StageVO = note.getBody() as StageVO;
switch ( note.getName() )
case ApplicationFacade.STAGE_RESIZED:
canvas.setSize(stageVO.screenW, stageVO.screenH);
case ApplicationFacade.SPLASH_SHOW:
//sendNotification will cause chain to next() using canvas as body for next chain link
canvas.init(stageVO.screenW, stageVO.screenH, styleProxy.style);
this.sendNotification( ApplicationFacade.SPLASH_INITIALIZED, canvas );
as it integrates into the framework using notifications the ChainNotifier can be dropped in place with a minimal of effort and helps maintain a loosely coupled system.

Syntax Overview:
Main ChainNotifier Constructor
 the class is conceptually a asynchronous queuing system referred to as a chain
 transition between nodes (links) is controlled through the use of notifications inthe pureMVC framework
 You can choose to override the default generated action trigger notifications names if needed, but should not be needed
 Base action names are appended to the Mediator name to insure unique action names for any givin ChainNotifier
 in this example , ChainNotifier("MYCHAINNAME"); ... would yeld MYCHAINNAME_ACTION_START, MYCHAINNAME_ACTION_STOP .. etc
 public function ChainNotifier( qname:String,
          qsetactive:String="_ACTION_SETACTIVE" ) :void
 eg: var chainNotifier:ChainNotifier = new ChainNotifier("MYCHAINNAME");
 @param qname - name of chain, If using defaults this name will be added to Action notification names
 @param qstart - Action start at the beginning of the queue and send first initial notification
 @param qstop - Action pause at current queue position, receiving of notifications except Actions, will be paused
 @param qcontinue - Action continue from pause position,activation of notifications will be enabled
 @param qend - Action skip to end node and send notification
 @param qnext - tAction node Move to nextAction Node and send notification , default behavior
 @param qprev - Action node Move back and repeat send notification
 @param qclear - Action will remove all nodes in array and free memory (no resart from this unless addNode/addAction is used
 @param qsetactive - experimental,not yet implemented with notifications however, can be triggered as method on the class
                     Active/Inactive will skip Inactive Nodes

* Notes: note.Body() and noteType() are sent to next link from prev notifyListener
*      Start will override all commands (pause, continue)
*       All Actions can be activated through the use of notifications and notification names overridden at constructor time
*      onRegister will start first notification, if you addNodes after this you will need to Start()

Function addNode
 This function provides the main method for sequentially adding notifications
 when its notifyListener notification is recived it moves to the next in the chain.
 This nex link then emits its notifySender notifications and waits for ITS notifyListener

 If you wish to use commands,  simply register your commands to take the chain links notifySender.
 when the command is called, at some point, either in the command or what the command is activating will
 need to send notification for the chain to be moved to next next point.

 eg. addNode( ApplicationFacade.SPLASH_SHOW, ApplicationFacade.SPLASH_INITIALIZED, note.getBody() ,note.getType());
     optional note.getBody() ,note.getType() can be set for the first Node to pass through, to the next node in the chain
     otherwise body and type are used from the received notifyListener and passed through to the next node in the chain
 @param notifySender  - the notification you wish to send when this link in the chain is triggered
 @param notifyListener - the notification this link will listen for to move to next link in chain
 @param body - an optional  notification body object to pass ( default is previous links notification body)
 @param type -  and optional notification type string to pass ( default is previous links notification type)
 @param active - to set a node inactive or active (testing whether this is useful) ( maybe placed before node function in a different release )

Function addAction
 This function provides a method to add Function callbacks triggered by notifications
 The Class uses this internaly  for adding the default Actions
 Although this is a little outside the box of its intended use it does provide a powerful
 triggering mechanism from within PureMVC the framework

 eg. addAction( "MY_ACTION_NOTIFICATION", myFunction);
     myFunction(node:ChainNotifierNode=null):void //function prototype for any addAction

 @param notifyListener - the notification this Action will listen for to call nFunction
 @param nFunction -  the function to call when triggered by notifyListener notifications

Flow Overview:
The constructor sets up Action notifications that can be used to control internal ChainNotifier behavior (if needed)
AddNode creates a node within the ChainNotifier supplying its name and start/next notification scheme.
OnRegister generates the first Action (if addNode includes a note body this is also sent with the notification)
dynamic listNotificationInterests register interest in the current index and Actions.
Upon receiving handleNotification either an Action is issued or the chain is moved to the next item and notification sent

In its basic operation it should not be necessary to use Actions , only if you want to get fancy or controll chain other next()
Simply copy the code into your view area and replace package naming
The code was designed using multi-core but can be replaced easily to standard (remove multicore name)

Comments or suggestions are welcome, if developers feel this is a worthy tool to be included I'll work with Cliff to create repository and package accordingly (as a utility)

Zip File
Latest Version


EDIT1: Removed Superfluous Naming and Added SetActive(), a few optimizations and added passing of getType()
EDIT2: AddNode documentation ,
EDIT3: Action Wording change in Docs and Code, Cliffs notes addressed
EDIT4: Version update, better wording of examples

Curtis [Trilec] 
4  Announcements and General Discussion / Architecture / Interesting AS3 Singleton Code on: April 17, 2008, 04:21:03
    public class Singleton
        public static var instance:Singleton;
        public static function getInstance():Singleton
            if( instance == null ) instance = new Singleton( new SingletonEnforcer() );
            return instance;
        public function Singleton( pvt:SingletonEnforcer )
            // init class
internal class SingletonEnforcer{}

Note: The class "SingletonEnforcer" is actually placed within the same .as file as the Singleton class, but placed outside the package{} parenthesis, therefore, the class "SingletonEnforcer" can only be accessed from within this .as file, so if the Singleton's constructor is called from anywhere else, you'll get an error.

reference: http://blog.pixelbreaker.com/category/flash/actionscript-30/

Also some interesting stuff on Performance Tuning by Gary Grossman

...it became clear that class constructors are interpreted, not JIT compiled, so all I had to do was move the code out of the constructor, into an init() function, and call if after the constructor, this shaved a huge amount of time off the initial build ...

5  Announcements and General Discussion / Getting Started / multitonKey for this Notifier not yet initialized! on: April 10, 2008, 03:36:34
Trying to understand this error:

Error: multitonKey for this Notifier not yet initialized!
   at org.puremvc.as3.multicore.patterns.observer::Notifier/get facade()
   at app.guildgrid.view::StageMediator()
   at app.guildgrid.control.command::ApplicationStartUpCommand/execute()
   at org.puremvc.as3.multicore.core::Controller/executeCommand()
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at org.puremvc.as3.multicore.patterns.observer::Observer/notifyObserver()
   at org.puremvc.as3.multicore.core::View/notifyObservers()
   at org.puremvc.as3.multicore.patterns.facade::Facade/notifyObservers()
   at org.puremvc.as3.multicore.patterns.facade::Facade/sendNotification()
   at app.guildgrid::ApplicationFacade/startup()
   at Application/creationComplete()
   at Application()
override public function execute(notification:INotification):void
  // Register the stage Proxy
  facade.registerProxy( new StageProxy() );
  // Register the main application Mediator, stage in this case
  facade.registerMediator( new StageMediator( Stage ) );
public class StageProxy extends Proxy implements IProxy

public static const NAME:String = "StageProxy";
/// Constructor
public function StageProxy(proxyName:String=null, data:Object=null)
super(NAME, new StageVO() );
/// Return data property cast to proper type
public function get stageVO():StageVO
return data as StageVO;
public static const NAME:String = 'StageMediator';
private var stageProxy:StageProxy; //reference to Proxie

public function StageMediator( viewComponent:Object )
  // stage viewComponent stored in the inherited (super) viewComponent property
   super( NAME, viewComponent );

  // Retrieve reference to frequently consulted Proxies
  stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;


override public function initializeNotifier(key:String):void
stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;

A better Fix: (based on Cliff Comments)
override public function onRegister():void
// Retrieve reference to frequently consulted Proxies
stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;

6  Announcements and General Discussion / Architecture / Social networking framework(singleton, multicore?) on: March 16, 2008, 06:23:20
Hi All,
just wanted to asked a design question as I'm beginning development of a small social networking based site.
It will have features such as:

login process

User tools
  • user details(login ID, account information)
  • user profile (what I like to wear, favorite food)
  • user gallery(images on may or may not share)
  • user interests(list of interests)
  • user a calendar(events I may or may not share)
  • and other i cont think of right now ... :-)
common tools
  • browser for anyone to search users
  • global events

Im trying to make it behave and appear like a single application (ie. full screen style)

My question is regarding the best approach to sectioning development.
singleton vs multicore?
An example might be using multicore
  • core1:login process (the main controlling app)
  • core2:user details/profile/gallery etc.
  • core3:any other common tools, browser etc
seems many other ways to split it up, including singleton...
I would greatly appreciate it if anyone can shed some light on a possible framework scenario.
or if you have done something similar and have found it to work efficiently.

As usual, thanks for any help, you guys rock..
7  Announcements and General Discussion / Public Demos, Tools and Applications / pureMVC example application Outlines on: March 14, 2008, 04:56:01
Hi all,
As I began expanding my horizons into the pureMVC framework I started outlining the demo source code.
Part of this outlining process was to simplify to the raw PureMVC functions and callbacks so I could see at a glance how the demo was structured and thus giving me more insite into the framework itself.

This is an example of these outlines, the question is does anyone else find this useful?
And if so where would be a good place to upload more of these.
Outlines for:  Cafetownsend , Bookstore , Arch101Demo and Helloflash.





Hope it helps
Pages: [1]