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 / Re: Getting started - proxys & ModelPrepCommand on: January 26, 2011, 02:06:48
Ah, this is the process of what I am working to achieve:

Before anything visual appears
  • 1. Load and parse - app_config.xml
  • 2. Load and parse - assets.xml (for bulkloader)
  • 3. Load and parse - containers.xml (application sprite or mc defined containers stack - eg getContainerById("overlay1") etc)
  • 4. Instantiate a singleton of embedded assets (1 x SWF for use with util I have getEmbeddedAssetClassById(str); and a list of simple font registrations and a collection of other assets needed for a bulkloader ui progress loader later)
  • 5. Application mediator - check assets.xml for asset count and preloader or not to preload and will have template code for textfield % done indicator but boolean available to not show bulkloader progress view component
  • 6. Application mediator - Clean up / remove bulkloader progress views
  • 7. Application mediator - Setup target projects ui and home screen (unknown at this time)

So you can see where I thought the prep came in handy, I needed the xml data to be loaded and parsed before we actually get into the applications target functionality and design.

I have noticed many examples I downloaded that didn't have modelPrepCommand.as and ViewPrepCommand and just goes straight to the StartupCommand.as, I think I will follow this route then as I can't see what I would actually place in these classes (model & view prepCommands.as).

The EmbeddedAssetsPrep came from an example I downloaded exampling usage of the twitter api. I guess that's not quite correct then.

I noticed the class path in your response for your constants was:
package net.zarqon.common.constantsI would have thought placing these in the model folder and if many a sub folder in the model folder would have been more appropriate? I would like to get a fixed folder structure, a pattern to lock down to and not deviate from, what are your thoughts on this?

I will alter my template application to work as follows, let me know if you have see anything wrong with this:

  • 1. Setup SWF & Instantiate the PureMVC
  • 2. ApplicationFacade.as (
  • 3. ApplicationStartupCommand.as - remove all addSubCommands and go straight for facade.registerMediator( new ApplicationMediator( note.getBody() ) );
  • 4. Application mediator - Instantiate singleton of embedded_assets.as (model folder)
    1 x SWF for use with getEmbeddedAssetClassByID(str);
    Font registrations
    and standard embed constants
    (* will have to check if singleton is needed here, don't want embeds to stack file size each time I use a constant)
  • 5. ApplicationMediator - Register proxy ApplicationConfigurationProxy.as
  • 6. ApplicationConfigurationProxy.as - Load app_config.xml, parse & dispatch notification success or fail
  • 7. ApplicationMediator - Register proxy BulkLoaderAssetsProxy.as
  • 8. BulkLoaderAssetsProxy.as - Load assets.xml, parse & dispatch notification success or fail
  • 7. ApplicationMediator - Register proxy ApplicationContainersProxy.as
  • 8. ApplicationContainersProxy.as - Load containers.xml, parse & dispatch notification success or fail
  • 9. ApplicationMediator - Setup bulkloader progress views (% loaded)
  • 10. Bulkloader - load asset list (NOT SURE HOW AND WHERE THIS FITS IN AT THE MOMENT)
  • 11. ApplicationMediator - Clean up bulkloader progress views (% loaded)
  • 12. ApplicationMediator - Setup target projects ui and home screen (project build begins)

I will create "NotificationConstants.as" in the model folder for holding all notifications bar "STARTUP".

My first real world test application of the above PureMVC skeleton will be a very basic 3D application. Regarding some details you gave me in my previous post ("getting started").

Previously stated you said enter frame handling would be done in the views, I'm assuming that I will be creating my 3DScene (blank) as a view with its own mediator. The view having an enter frame which is handling rendering the 3D scene and 3D scene camera positioning and animation.

In most of my 3D applications, this would be where I perform animation on multiple 3D objects and on camera direction and position. Now assuming this is a view component in the PureMVC, this would mean that this view is aware of many other views (3D objects in the scene)? Is this allowed in the PureMVC? Is a view supposed to be aware and manipulate other views? What's your thoughts & suggestions on this?

An example would be a 3D scene with a carousel and hover camera, where I click on an item in the carousel. Each item is a view component, and has its own animation for rotation tweens but the positions in the 3D scene of each view would be manipulated in relation to camera direction, camera position and which item in the carousel was clicked resulting in quite varied animation.

Thanks again for all your help,

2  Announcements and General Discussion / Getting Started / Getting started - proxys & ModelPrepCommand on: January 26, 2011, 04:13:45

I am building my template application and wanting 3 xml files to be loaded before my application starts to do anything related to the project it will be implemented on.

I have in my ApplicationStartupCommand.as the following:

        override protected function initializeMacroCommand() :void

// I want a sequential command process here
// 1. Model prep
// 2. Embedded assets prep
// 3. View prep

// Model prep on success will call embedded assets prep
// Embedded assets prep will call view prep
// View prep will register application mediator

            addSubCommand( ModelPrepCommand );

The proxy will load a local xml file, what I need is the command to listen for notifications (success or fail).

On success: addSubCommand( EmbeddedAssetsPrepCommand );

Which will just call a singleton of a embedded assets class and then add the final subCommand ( viewPrepCommand ), which in the puremvc template registers the application mediator.

Question 1:
How should a command listen for a notification if I can't use
override public function handleNotification( note:INotification ):void  ?

Question 2:
Or should I just ignore the possibilities of failure at this stage of the puremvc and assume that the xml file will always be in existence? And just place all subCommands in the ApplicationStartupCommand?

Question 3:
If I were to have a large scale application with many many many events being listened for and reacted upon, would the ApplicationFacade still have hard coded in constants for each of these events?


3  Announcements and General Discussion / Getting Started / Re: Getting started on: January 24, 2011, 03:08:09
Excellent, ok think I'm on the right path now.

Thanks for all the help with my questions :)
4  Announcements and General Discussion / Getting Started / Re: Getting started on: January 24, 2011, 12:36:56
ok after watching single core video (got direct link for flv download?), this is what I presume to understand now:

Create the visual elements
Functions for animation on the view component

Event notification listener to trigger view functions
Call commands

Proxy handling
Dispatch notifications for mediators & views to pickup

Question 1
If the above is correct, would a view contain an enter frame event listener and function to handle enter frame animation?

Question 2,3,4,5
For a 3D scene, on collision detection of lets say randomly 10 3d objects, each with different animations depending on the type of object pair collision, where would the enter frame collision detection code be placed, as a mediator shouldn't perform logic and a command is short lived? or is this an exception?

The googling continues...  Thanks again.

5  Announcements and General Discussion / Getting Started / Re: Getting started on: January 23, 2011, 11:17:31
ok seems I'm not thinking on the right path here.... :\   I'm a bit confused on the roles of the mediator and the command. Is this correct?

Mediators do nothing apart from instantiate other mediators passing view components to them and listen to notification events which the mediator would call a function in the corresponding view components to update themselves, animate etc

Are the applications performance logic.
So, they get references to mediators and view components to perform logic on them (or would the logic of animation be partly done in the views?). How would 2 balls colliding in a 2D or 3D scene work? Would a command hold multiple references to multiple mediators and the view components performing logic on them eg enter_frame events if sometimes necessary? Would a command handle enter_frame logic?

Regarding preloader.
I am wanting to include bulkloader in my puremvc template application, my picture on how to do this now is to, create bulkloader proxy, bulkloader mediator, bulkloader view (progress bar). A command would be run which would setup a proxy, then the command would run a mediator which in turn would setup a preloader ui? Is this correct?

In response to your question:
Is this a multicore project? If you're loading a module that uses PureMVC, it needs to be, so that there is a separate facade for each module.
No, I am in the habit of referring to a RIA,Webpage etc's pages, different sections as modules.

Thanks again.

6  Announcements and General Discussion / Getting Started / Re: Getting started on: January 19, 2011, 10:55:40
Excellent! thank you for all this help and info, has been pivotal, I find so many contradictions in what should go where googling all this stuff..

I have a framework called the AFTC, which is a modular framework which is a combination of factory, singleton and observer patterns. Included are 1 x XML doc for sprite/mc application container structure, 1 x XML config, embedded assets manager, preloader via bulkloader, various managers for assets and fonts etc. The AFTC simply allows a dev to simply copy and paste the base template and create a folder for each module of the application to work within for each module of their application. All of this weighs in around 12Kb, I am wishing to re-create this using the PureMVC so I can just copy and paste my template app and have access to all the essential managers, assets and utilities from my AFTC framework, so I can keep Rapid Application Development just using the PureMVC.

Hopefully last question before I get back into test app city.

Narrowing down things in a more general sense would lock my application and all future applications I build into this layout:

  • Call functions from proxies
  • Send notifications for mediators to update their view components on data notifications received from proxie (failed or changed)

  • Add view components to the stage/display (to give references to their relative mediators)
  • Instantiate other mediators
  • Perform logic for positioning and animation of view components (eg tweens etc)
  • Handle events from commands
  • Handle events from other mediators when required

Model (not coded any self test examples yet but I think its)
  • Loading of data
  • Loading error event dispatching caught by commands
  • Loading success event dispatching caught by commands
  • Loading progress event dispatching caught by commands (would a command dispatch another event for a mediator to pick up for progress loading for example or would a developer skip this and let the mediator listen to the proxies progress event?)
  • Vo (not quite sure on this classes role, just a list of variable declerations which are accessible?)
  • Proxy (not quite sure on this classes role, just a list of variable declerations which are accessible?)

Regarding my template app for future projects, I would:
  • In prep model - I will setup proxy for config xml (local file)
  • In prep model - I will setup proxy for assets xml (local file)
  • In prep model - I will setup proxy for containers xml (local file)
  • In prep model - I will setup proxy for accessing assets from bulkloader
  • In prep view - I will init embedded assets (0kb swf containing assets for preloader only - after flex prelloader init (if flex))
  • Application mediator - Init blank view component for preloader (calls success as default to proceed)
  • AssetPreloaderMediator - Execute preloader mediator
  • AssetPreloaderMediator - On preloader mediator complete - proceed with main application
  • MainApplicationMediator - Ini global stage ui views
  • MainApplicationMediator - Ini nav view
  • MainApplicationMediator - pass global ui views and nav views to their mediators via mediat init
  • MainApplicationMediator - Call starting module mediator to start homepage for target project

Let me know if I am going down the wrong path here. or am I thinking in the wrong way in implementation.

Thanks again

7  Announcements and General Discussion / Getting Started / Re: Getting started on: January 18, 2011, 02:03:02
Excellent thanks for info :)

However I'm not 100% on the vocab of the pureMVC, not quite sure on:

I'd probably have the StageMediator be interested in a PLACE_OBJECT_RANDOMLY note, and handle it by taking the DisplayObject out of the body of the note, adding random x/y coords and adding it to the stage. Any other actor could create the display object and send the note.

 "PLACE_OBJECT_RANDOMLY note"? - I assume by this you mean a "placeObjectRandomly(do:DisplayObject)" function but where? I assumed a command which would have been run in the "NotificationHandler" function of the ApplicationMediator?

Any other actor could create the display object

"Actor"? Is this the pureMVC communities ref to a Mediator?

And finally my picture of what happens in my applications mediators is now this, just to clear things a little more, is this correct?

Application Mediator (On my hello world application)
   - Register any mediators required
   - Instantiate any views
   - Setup "notification handler"
   - "Notification handler" exec commands via sendNotification via the facade to position "sprite"
            - "Mouse button stage up" notification:
               Instantiates hello world view text component and sends a notification
               via sendNotification for a command to position HelloWorld text randomly on x & y
               (how can the command get the view components reference for positioning?
               & how can the command get the stage? or reference to any required mediators?)

and for my next test build with preloader, closer to a template I will work from would be something like

Application Mediator (On my preloader application)
   - Register any mediators required for preloader UI
   - Setup "notification handler"
   - sendNotification(STARTUP,{setup}); to trigger Notification Handler here to setup preloader UI
   - "Notification handler" exec commands via sendNotification via the facade to handle
            - "Preloader UI setup" notification
            - "Preloader animation in" notification
            - "Preloader animation progress" notification
            - "Preloader animation out" notification
            - "Preloader ui dispose" notification
            - "Setup global UI components" notification (for nav etc)
            - "Start main application" notification
            - Application nav shared event adjust ui for nav option 1 press (also handled in Navi mediator)
            - Application nav shared event adjust ui for nav option 2 press (also handled in Navi mediator)
            - etc
8  Announcements and General Discussion / Getting Started / Getting started on: January 18, 2011, 07:37:27

I have just created a hello world example and have a few questions if anyone can clarify a few things before I proceed that would be great.

Q1. I have a stage mediator registered from my ApplicationMediator, this stage mediator dispatches mouse up notifications. I am randomly placing the hello world text on x and y. Where should the random x and y be calculated? Is it best practice to place the random positioning logic for the placement of the hello world view component in the ApplicationMediator via its handleNotification function where the view component is instantiated or should this be done via a command? If it's a command how do I get the reference of the view component added to the stage for x and y placement?

Q2. Registering mediators inside mediators is this correct? or should they all be registered in a centralised place for better management?

Q3. If mediators register and handle other mediators, should they be able to obtain references to other mediators? If yes how do we get the reference to the created mediator?

Q4. If for example I am building an application that has an empty container as a view, to which I add views to it later. Where would the logic go for adding view components to a view? If this is a mediator, im guessing a command would be created for listening to added for listening to events from the mediator for handling things to do when added and when removed?

Q5. If I have a 3D Scene as a view (which is default blank), and then create separate view components which can be added to the 3D Scene view, should the 3D scene view be a view or a mediator? Im guessing mediator for calling the view component (3D scene), then same mediator to listen to events and have code in it to add 3D objects to the view component or is this a more complicated scenario of many commands, mediators and views?

For a moment there while typing this I thought I clarified things for myself, then I re-read it and now think the opposite lol...

To visualise things I created some process flow class diagrams to illustrate how I think the PureMVC is actually laid out.

So the main application would be laid out like so:

Mediators would all be like so:

and all commands like so:

This look correct?

Any info is much appreciated.


Pages: [1]