Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
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?
To visualise things I created some process flow class diagrams to illustrate how I think the PureMVC is actually laid out. This look correct?
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.
Any other actor could create the display object
"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?
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?)
QuoteAny other actor could create the display object"Actor"? Is this the pureMVC communities ref to a Mediator?
Application Mediator (On my preloader application)
Perform logic for positioning and animation of view components (eg tweens etc)
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?)
AssetPreloaderMediator - Execute preloader mediator
MainApplicationMediator - Call starting module mediator to start homepage for target project.
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.
Would a command hold multiple references to multiple mediators and the view components performing logic on them eg enter_frame events if sometimes necessary?
the command would run a mediator which in turn would setup a preloader ui? Is this correct?
MediatorsEvent notification listener to trigger view functionsCall commands
Question 1If the above is correct, would a view contain an enter frame event listener and function to handle enter frame animation?
Question 2,3,4,5For 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?