RE: [Flashcoders] Using MVC for a site framework
This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); } private function onControllerInitialized(event:ControllerEvent):void { controller.removeEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); dispatchEvent(new MVCEvent(MVCEvent.INITIALIZED)); } public static function get instance():MVC { if ( _instance == null ) { throw new Error( MVC singleton instance not created yet. ); } return _instance; } } } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 11:09 AM To: Flash Coders List Subject: [Flashcoders] Using MVC for a site framework Hi guys I'm currently feeling my way through the o'reilly design patterns book and am going through the
Re: [Flashcoders] Using MVC for a site framework
very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); } private function onControllerInitialized(event:ControllerEvent):void { controller.removeEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); dispatchEvent(new MVCEvent(MVCEvent.INITIALIZED)); } public static function get instance():MVC { if ( _instance == null ) { throw new Error( MVC singleton instance not created yet. ); } return _instance; } } } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January
RE: [Flashcoders] Using MVC for a site framework
The view can hold an array of other views, when the main view is told to build by the controller, it iterates through the array to tell the other view instances or whatever. Shouldn't be hard to implement. My method does not depend on a single view, it's really just how you want to structure it. It will also allow the controller to tell a particular view to build, i.e.: //in the controller: private function onSomething(event:Event):void { if(somethingSpecial) _mvc.view.mySpecialView.build(); } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); }
Re: [Flashcoders] Using MVC for a site framework
okay that's kinda what i thought thanks for your help jason a On Tue, Jan 19, 2010 at 5:24 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: The view can hold an array of other views, when the main view is told to build by the controller, it iterates through the array to tell the other view instances or whatever. Shouldn't be hard to implement. My method does not depend on a single view, it's really just how you want to structure it. It will also allow the controller to tell a particular view to build, i.e.: //in the controller: private function onSomething(event:Event):void { if(somethingSpecial) _mvc.view.mySpecialView.build(); } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); }
Re: [Flashcoders] Using MVC for a site framework
Jumping in here.. The controller is essentially co-coordinating the interactions between the views and the model. You could consider the role of setting up the application view interfaces as being subsidiary to the controller, or even outside of it (after all the application has to instantiate things at the start). I don't see that the Model is ever involved with view instantiation. I only see the model as a provider of stateful data, so in this context something outside the Model should request the configuration from the model (which is responsible for loading the xml config). I'm not sure if the application setup is a consideration of the controller or not. There's no reason why it shouldn't be a function of the controller - after all the controller invokes commands at the request of the views for everything else, so there's no reason why it can't handle initialisation. The important thing is that the Model is not dependent or knowledgeable about the views that form the application interface. Paul allandt bik-elliott (thefieldcomic.com) wrote: very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); } private function
RE: [Flashcoders] Using MVC for a site framework
Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); } private function onControllerInitialized(event:ControllerEvent):void { controller.removeEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); dispatchEvent(new MVCEvent(MVCEvent.INITIALIZED)); } public static function get instance():MVC { if ( _instance == null ) { throw new Error( MVC singleton instance not created yet. ); } return _instance; } }
Re: [Flashcoders] Using MVC for a site framework
Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. I recommend the head first design patterns book. Not only can I guarantee that you will actually get it, you will have fun while doing it! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Using MVC for a site framework
I have read Design patterns from O'Reilly but it does not dig in -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: dinsdag 19 januari 2010 20:24 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. I recommend the head first design patterns book. Not only can I guarantee that you will actually get it, you will have fun while doing it! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 270.14.149/2631 - Release Date: 01/19/10 08:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Using MVC for a site framework
I even received a MVC for an appalication I was building from Muzak, but that is just a little to much to comprehend at this time. I need to understand it from a little and very basic example to start with. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: dinsdag 19 januari 2010 20:24 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. I recommend the head first design patterns book. Not only can I guarantee that you will actually get it, you will have fun while doing it! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 270.14.149/2631 - Release Date: 01/19/10 08:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using MVC for a site framework
There is a nice tutorial on lynda.com done by Todd Perkins I believe. It is a very simple MVC flash application. If you planned on taking advantage of other tutorials on there, then it might be worth the subscription cost. --Original Message-- From: Cor Sender: flashcoders-boun...@chattyfig.figleaf.com To: 'Flash Coders List' ReplyTo: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework Sent: Jan 19, 2010 1:31 PM I even received a MVC for an appalication I was building from Muzak, but that is just a little to much to comprehend at this time. I need to understand it from a little and very basic example to start with. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: dinsdag 19 januari 2010 20:24 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. I recommend the head first design patterns book. Not only can I guarantee that you will actually get it, you will have fun while doing it! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 270.14.149/2631 - Release Date: 01/19/10 08:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using MVC for a site framework
Merrill, Jason wrote: The view can hold an array of other views, Any new views can request to be added to the listener/notify list using the observer pattern, as in please inform me too, if things change. John when the main view is told to build by the controller, it iterates through the array to tell the other view instances or whatever. Shouldn't be hard to implement. My method does not depend on a single view, it's really just how you want to structure it. It will also allow the controller to tell a particular view to build, i.e.: //in the controller: private function onSomething(event:Event):void { if(somethingSpecial) _mvc.view.mySpecialView.build(); } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void {
RE: [Flashcoders] Using MVC for a site framework
Thanks, Nathan! -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik Sent: dinsdag 19 januari 2010 20:42 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework There is a nice tutorial on lynda.com done by Todd Perkins I believe. It is a very simple MVC flash application. If you planned on taking advantage of other tutorials on there, then it might be worth the subscription cost. --Original Message-- From: Cor Sender: flashcoders-boun...@chattyfig.figleaf.com To: 'Flash Coders List' ReplyTo: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework Sent: Jan 19, 2010 1:31 PM I even received a MVC for an appalication I was building from Muzak, but that is just a little to much to comprehend at this time. I need to understand it from a little and very basic example to start with. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: dinsdag 19 januari 2010 20:24 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. I recommend the head first design patterns book. Not only can I guarantee that you will actually get it, you will have fun while doing it! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 270.14.149/2631 - Release Date: 01/19/10 08:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 270.14.149/2631 - Release Date: 01/19/10 08:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using MVC for a site framework
Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function onViewInitialized(event:ViewEvent):void { addChild(view); view.removeEventListener(ViewEvent.INITIALIZED, onViewInitialized); controller.initialize(); } private function onControllerInitialized(event:ControllerEvent):void { controller.removeEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); dispatchEvent(new MVCEvent(MVCEvent.INITIALIZED)); } public
RE: [Flashcoders] Using MVC for a site framework
Any new views can request to be added to the listener/notify list using the observer pattern, as in please inform me too, if things change. Right - I was trying to keep things simple for the poster. Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: Tuesday, January 19, 2010 2:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Merrill, Jason wrote: The view can hold an array of other views, Any new views can request to be added to the listener/notify list using the observer pattern, as in please inform me too, if things change. John when the main view is told to build by the controller, it iterates through the array to tell the other view instances or whatever. Shouldn't be hard to implement. My method does not depend on a single view, it's really just how you want to structure it. It will also allow the controller to tell a particular view to build, i.e.: //in the controller: private function onSomething(event:Event):void { if(somethingSpecial) _mvc.view.mySpecialView.build(); } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void
RE: [Flashcoders] Using MVC for a site framework
My version is ActionScript 3 Design Patterns by William Sanders Chandima Cumaranatunge. The MVC there is describe as a combination of several other patterns. The books is good, but I have to start at one level below that. Is there somewhere a shareable example of the MVC pattern?? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: dinsdag 19 januari 2010 20:48 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED, onModelInitialized); view.initialize(); } private function
RE: [Flashcoders] Using MVC for a site framework
If you have an iPhone or iTouch, O'Reilly has the digitial version of ActionScript 3 Design Patterns for download to iPod Touch/iPhone for only $5. A steal for that price, and the iPhone reader app that comes built in with it works very nice. You can find it on the App store (I think I found it by searching for Actionscript). Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: Tuesday, January 19, 2010 2:48 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); }
RE: [Flashcoders] Using MVC for a site framework
Cor, if I can find some time, I'll try and send you a simple MVC example. We'll see how tonight goes with my 2 year old. Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: Tuesday, January 19, 2010 2:55 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Using MVC for a site framework My version is ActionScript 3 Design Patterns by William Sanders Chandima Cumaranatunge. The MVC there is describe as a combination of several other patterns. The books is good, but I have to start at one level below that. Is there somewhere a shareable example of the MVC pattern?? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: dinsdag 19 januari 2010 20:48 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller();
RE: [Flashcoders] Using MVC for a site framework
Jason, GREAT!!! Thank you. I hope the little one lets you rest. ;-) Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 20:58 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework Cor, if I can find some time, I'll try and send you a simple MVC example. We'll see how tonight goes with my 2 year old. Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: Tuesday, January 19, 2010 2:55 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Using MVC for a site framework My version is ActionScript 3 Design Patterns by William Sanders Chandima Cumaranatunge. The MVC there is describe as a combination of several other patterns. The books is good, but I have to start at one level below that. Is there somewhere a shareable example of the MVC pattern?? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: dinsdag 19 januari 2010 20:48 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else {
RE: [Flashcoders] Using MVC for a site framework
Cor, I've found it the other way - trying to find complex examples of MVC are hard - there are heaps of overly simple ones that don't really tell me a lot about wiring complicated applications together. Also, I recommend you take any advice/examples objectively. There are many ways to skin an MVC cat. Some frameworks are tightly coupled, some are loosely coupled, some use dependency injection, some don't. Some peoples examples have the logic in the controller, some in the model. Some people use the controller to load data and the model to store it. Some people extend the metaphor to MVCS (S for service - using service classes to load external data). There are so many different takes on it. Here's a really basic tutorial fwiw. Again, I'm not sure I agree with all of the methods involved, but like anything you can watch and learn from it and apply the bits that make sense to you. http://pv3d.s3.amazonaws.com/videos/tutorials/actionscript3/mvc/mvc.mp4 Personally, the more I look into Robotlegs the more I like it. Especially now people are starting to consider AS3Signals as the event method. This writeup says it all for me: http://alecmce.com/library/robotlegspong1 There's even source code to check the whole thing out. Barry. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: Wednesday, 20 January 2010 9:00 a.m. To: 'Flash Coders List' Subject: RE: [Flashcoders] Using MVC for a site framework Jason, GREAT!!! Thank you. I hope the little one lets you rest. ;-) Cor -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 20:58 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework Cor, if I can find some time, I'll try and send you a simple MVC example. We'll see how tonight goes with my 2 year old. Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor Sent: Tuesday, January 19, 2010 2:55 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Using MVC for a site framework My version is ActionScript 3 Design Patterns by William Sanders Chandima Cumaranatunge. The MVC there is describe as a combination of several other patterns. The books is good, but I have to start at one level below that. Is there somewhere a shareable example of the MVC pattern?? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: dinsdag 19 januari 2010 20:48 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary
Re: [Flashcoders] Using MVC for a site framework
I have that book too but the Joey Lott book is clearer (for me). They have code samples here: http://rightactionscript.com/aas3wdp/ The book is a very good. John Cor wrote: My version is ActionScript 3 Design Patterns by William Sanders Chandima Cumaranatunge. The MVC there is describe as a combination of several other patterns. The books is good, but I have to start at one level below that. Is there somewhere a shareable example of the MVC pattern?? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: dinsdag 19 januari 2010 20:48 To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Cor, I am only familiar with a part of it but the book ActionScript 3 Design Patterns by Joey Lott and Danny Patterson from Adobe Press has a nice example using an analogue and digital clock but only one set of data. You can imagine a wrist watch view asking to get informed when the time changes. John Cor wrote: Hi Jason, I hope you don't mind me addressing you of list. If you do, please ignore this message and I apologize to you! I am trying to grasp the MVC pattern, but it is very hard for me. I am looking for a very simple example which explains the way it works. If you can help me with this, I would be very greatful. Thanks in advance. Kind regards Cor van Dooren The Netherlands -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: dinsdag 19 januari 2010 17:35 To: Flash Coders List Subject: RE: [Flashcoders] Using MVC for a site framework This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model; public var controller:Controller; private static var _instance:MVC; public function MVC() { if ( _instance != null ) { throw new Error( Only one MVC instance should be instantiated. Use MVC.instance instead. ); } else { _instance = this; } } public function initialize():void { model = new Model(); view = new View(); controller = new Controller(); model.addEventListener(ModelEvent.INITIALIZED, onModelInitialized); controller.addEventListener(ControllerEvent.INITIALIZED, onControllerInitialized); view.addEventListener(ViewEvent.INITIALIZED, onViewInitialized); model.initialize(); } private function onModelInitialized(event:ModelEvent):void { model.removeEventListener(ModelEvent.INITIALIZED,
Re: [Flashcoders] Using MVC for a site framework
I need things pretty simple too, but he did mention new views and adding them in. Also, the books I have read say you often get combination of patterns and that you need that distance between view and model that Observer brings. Maybe I am 'Observer' fixated because it just made a big difference to my C++ code. Model:flashcoders Views:Firefox,Thunderbird, I.E., PC, MAC, Linnux Controller:the pipework John Merrill, Jason wrote: Any new views can request to be added to the listener/notify list using the observer pattern, as in please inform me too, if things change. Right - I was trying to keep things simple for the poster. Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: Tuesday, January 19, 2010 2:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework Merrill, Jason wrote: The view can hold an array of other views, Any new views can request to be added to the listener/notify list using the observer pattern, as in please inform me too, if things change. John when the main view is told to build by the controller, it iterates through the array to tell the other view instances or whatever. Shouldn't be hard to implement. My method does not depend on a single view, it's really just how you want to structure it. It will also allow the controller to tell a particular view to build, i.e.: //in the controller: private function onSomething(event:Event):void { if(somethingSpecial) _mvc.view.mySpecialView.build(); } Jason Merrill Bank of America Global Learning Learning Performance Soluions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt bik-elliott (thefieldcomic.com) Sent: Tuesday, January 19, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] Using MVC for a site framework very cool jason - thanks just a quick question - this setup works perfectly where the number of views is known, but how would you implement that with an unknown amount of views? or is this the setup for the root view with all other views being add()ed to it? thanks mate a On Tue, Jan 19, 2010 at 4:35 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: This is my opinion, I'm sure others will have their own that may differ (and probably recommend you check out some frameworks - though that can be a lot to tackle) : the controller would listen to the model to know when the data is ready and available. It would then tell the view to start building. The main class would hold the references to the model, view, controller, but would not command any classes to do anything really. You could have the view listen to the model as well and skip the controller doing it, but I like the view to be more decoupled than that. I usually try and keep most listeners in the controller where possible, though many end up in the view, depending on the situation. I never have listeners in the model though, only events that are dispatched. I actually have the model start and do it's own XML loading, but you could have the controller tell it to do that, just seems like an unnecessary step. Another thing I do is have a main class called MVC that extends Sprite or DisplayObject which initializes the model, view, controller, in order, dispatches an event when all three are initialized, and provides access to each via a singleton implementation. It allows me to access any part of a model, view, controller from any other part just by calling MVC.instance. Then it's just var _mvc:MVC = MVC.instancel; then _mvc.model.myprop or _mvc.view.update() or whatever. That class looks like this: package mvc { import events.MVCEvent; import events.view.ViewEvent; import events.controller.ControllerEvent; import events.model.ModelEvent; import mvc.controller.Controller; import mvc.model.Model; import mvc.view.View; import flash.display.Sprite; /** * ... * @author Jason Merrill - Bank of America */ public class MVC extends Sprite { public var view:View; public var model:Model;
Re: [Flashcoders] Using MVC for a site framework
Want to do MVC right? Use this: http://www.robotlegs.org/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] SOLVED Crossdomain.xml, shared hosting, https, oh my!
Hi Steven, It was a pleasure chatting with you yesterday. We feel that your background is potentially suitable for our ActionScript programmer position. At this point, we are in the initial phone conversation phase with candidates and should have more information on who we will continue through the process in about 2 weeks time. I will contact you if we decide to move forward. Thanks again, Kathy On Fri, Jan 15, 2010 at 12:47 PM, Steven Loe stevenloe5...@yahoo.comwrote: Just wanted to post back that this is solved, so that it may help someone else: I found that I had to load both of the policy files over https in order to make the crossdomain policy take effect. First line of the document class' constructor: Security.loadPolicyFile('https://stage.example.com/crossdomain.xml'https://stage.example.com/crossdomain.xml%27 ); Security.loadPolicyFile('https://stage.example.com/game/crossdomain.xml'https://stage.example.com/game/crossdomain.xml%27 ); Happy OK message in my policyfiles.txt log: OK: Request for resource at https://stage.example.com/game/direct_paymentby requestor from http://stage.example.com/media/swf/game.swf is permitted due to policy file at https://stage.example.com/game/crossdomain.xml Crossdomain.xml files and web service paths are as below: Thanks! Now that this is working, I can play with getting rid of the '*' The swf is loaded via http at http://stage.example.com/media/swf/game.swf The credit card data is Loaded/sent via https at https://stage.example.com/game/direct_payment Policy File 1 is here: http://stage.example.com/crossdomain.xml Policy file 2 is here: http://stage.example.com/game/crossdomain.xml: Policy File 1: ?xml version=1.0 encoding=utf-8? !DOCTYPE cross-domain-policy SYSTEM 'http://www.adobe.com/xml/dtds/cross-domain-policy.dtd' cross-domain-policy site-control permitted-cross-domain-policies=all/ allow-access-from domain=*/ /cross-domain-policy Policy file 2: ?xml version=1.0 encoding=utf-8? !DOCTYPE cross-domain-policy SYSTEM 'http://www.adobe.com/xml/dtds/cross-domain-policy.dtd' cross-domain-policy allow-access-from domain=*.example.com secure=false/ /cross-domain-policy ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] How this is done?
http://en.tackfilm.se/?id=1263055474592RA80 http://en.tackfilm.se/?id=1263055474592RA80 -- Cheers, skooviya ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] **TODAY** Developers: Flash Platform -- Building State of the Art Video and Media Players ** Online-only, Public User Group Meeting -- TODAY Wednesday January 20 @ 12:00 NOON PST
The online-only OSMF User Group http://groups.adobe.com/groups/7af970e6e4is pleased to have a live presentation **TODAY** on OSMF's new features by a developer from the OSMF Team, Edwin van Rijkomhttp://nl.linkedin.com/in/vanrijkom, Sr. Computer Scientist at Adobe. This meeting is open to all who are interested. Please forward notice about this meeting to all who you think may be interested. The link for the online meeting room can be found in the meeting announcement link here: http://groups.adobe.com/posts/3e8fddb492 Edwin will be reviewing changes and new features in OSMF delivered in Sprint 8 (released December), as well as providing an overview of new features in Sprint 9 (releasing next week). Topics to be covered include: - API Refactoring Changeshttp://opensource.adobe.com/wiki/download/attachments/34373765/ReleaseNotesv08.pdf - Subclip Supporthttp://opensource.adobe.com/wiki/display/osmf/Subclip+Specification - Live Streaming Supporthttp://opensource.adobe.com/wiki/display/osmf/Live+Support+Mini-Spec - Flash Media Manifest File Formathttp://opensource.adobe.com/wiki/display/osmf/Flash+Media+Manifest+File+Format+Specification(F4M) Support - Multi-BitRate (MBR) Streaming; - Digital Rights Management (DRM) via Flash Accesshttp://www.adobe.com/products/flashaccess/, - For full details see specification herehttps://mail.google.com/mail/html/compose/static_files/Flash%20Media%20Manifest%20File%20Format%20Specification - Closed Captioning Plug-inhttp://opensource.adobe.com/wiki/display/osmf/Captioning+Plugin - Pre-Assigned Durationshttp://help.adobe.com/en_US/OSMF/1.0/AS3LR/org/osmf/video/VideoElement.html#defaultDuration Edwin previously presented at the Adobe MAX 2009 conference as a co-presenter on the session entitled Introduction to Adobe's Open Source Media Framework. Following is a link for a recording of Edwin's MAX Session (Edwin's portion starting at 24:00 in the recording timecode): http://max.adobe.com/online/session/332 OSMF is an open source ActionScript 3 framework for building video and media players supporting cutting edge Flash Platform features for media delivery. If you have any curiosity about media players in Flash or Flex, this is a great forum for exploring and getting questions answered. If you have an ongoing interest in this area, *please join this group by logging in **at **groups.adobe.com/groups/7af970e6e4*http://groups.adobe.com/groups/7af970e6e4 * and selecting the JOIN THIS GROUP link* (red graphic on right side). This online-only OSMF User Group http://groups.adobe.com/groups/7af970e6e4meets regularly at this time and day of every month. That is the 3rd Wednesday of every month @ 12:00 NOON PST time [Time Zone Converter herehttp://www.timeanddate.com/worldclock/converter.html]. All meetings are recorded. Links for prior meeting recordings are on the group site in various places including on the group home pagehttp://groups.adobe.com/groups/7af970e6e4under the heading Previous Connect Sessions. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders