Hi everybody,
I am new to PureMVC and I am still figuring it out and some times it's hard to get my head around it but i guess it's part of the learning process.
Ok I have this ViewCommand that is being triggered when all data is loaded and this ViewCommand creates a ViewMediator on execution. The ViewMediator waits for a notification ViewMediator.CREATE_VIEW, so it can start creating display elements.
The VIEW_COMPLETE is triggered when all the view objects are created in a other Class called AnimationView. The animation View does the actual creating of the objects and then inside the mediator I addChild this AnimationView to the viewComponent.
So the next step I want to do is animate all those objects inside the AnimationView.
I wonder how to do this in the best way. Should I make some kind of construction that sends a notification to the ViewCommand and then send a other notification where the mediator listens to, so it can execute the startAnimation function in the ViewMediator and the viewMediator can execute the startAnimation within the view? Or should i do this with regular event listeners between the mediator and the view?
I hope it's a bit clear, but basically this is the code:
package nl.adlantic.app.views {
import nl.adlantic.app.models.AnimationProxy;
import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;
public class ViewMediator extends Mediator implements IMediator {
public static const NAME : String = "ViewMediator";
public static const CREATE_VIEW : String = NAME + "CreateView";
public static const VIEW_COMPLETE : String = NAME + "CompleteView";
public static const START_ANIMATION : String = NAME + "StartAnimation";
private var animationView : AnimationView;
public function ViewMediator(viewComponent : Object) {
super(NAME, viewComponent);
}
override public function onRegister() : void {
super.onRegister();
}
override public function listNotificationInterests() : Array {
return [ViewMediator.CREATE_VIEW];
}
override public function handleNotification(notification : INotification) : void {
super.handleNotification(notification);
viewComponent = notification.getBody();
createViews();
}
private function createViews() : void {
animationView = new AnimationView(animationProxy.animationData());
viewComponent.addChild(animationView);
sendNotification(ViewMediator.VIEW_COMPLETE);
}
private function startAnimation():void{
// EXECUTE ANIMATION
// animationView.animate();
}
private function get animationProxy():AnimationProxy{
return facade.retrieveProxy(AnimationProxy.NAME) as AnimationProxy;
}
}
}