PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: ryac on August 16, 2008, 11:59:16



Title: first MVC app based on an example from AS3.0 Design Patterns
Post by: ryac on August 16, 2008, 11:59:16
hi all,

I've taken one of the MVC examples from the Actionscript 3.0 Design Patterns book, "Weather Maps" and made it into a pureMVC app but want to know if I'm on the right track with it (I'm using Flash CS3). it works fine, but - on top of having someone take a look at the source and checking to see if it looks right - I have some questions about setting things up:

1. do I need to register all commands in the concrete facade?
2. do I need to register all proxies and views in the StartupCommand (all apps will need some kind of StartupCommand, right?)
3. does every input / change in the view need to be connected to a command, and is it one command per view?
4. will all notification name constants be placed in the ApplicationFacde class? it seems that there will be "pairs" of constants too. for example: KEYPRESS and KEYUPDATE (I need to send a notification with the name KEYPRESS to a command, and then listen to the notification KEYUPDATE in a view). is that correct? looks like you can end up with a lot of constants that way..

the source can be found here: www.ryac.ca/source.zip

thanks a lot for your time!

regards,
Ryan



Title: Re: first MVC app based on an example from AS3.0 Design Patterns
Post by: puremvc on August 17, 2008, 05:07:27
Hi Ray,

1. do I need to register all commands in the concrete facade?

No. They can be registered and removed dynamically at runtime by other commands.
 
2. do I need to register all proxies and views in the StartupCommand (all apps will need some kind of StartupCommand, right?)

No. Typically you will have a StartupCommand, yes, but you don't have to register all Mediators and Proxies there. Just like Commands, they can be registered and removed dynamically at runtime.

3. does every input / change in the view need to be connected to a command, and is it one command per view?

No. Mediators are pretty useful too. For instance If you just need to set a data item from the view onto a Proxy from a view component you may skip the Command and do it in the Mediator.

4. will all notification name constants be placed in the ApplicationFacde class? it seems that there will be "pairs" of constants too. for example: KEYPRESS and KEYUPDATE (I need to send a notification with the name KEYPRESS to a command, and then listen to the notification KEYUPDATE in a view). is that correct? looks like you can end up with a lot of constants that way.

The concrete Facade is just a handy place for constants that will be shared by notification participants. They could go into a separate constants file if you wish.

-=Cliff>


Title: Re: first MVC app based on an example from AS3.0 Design Patterns
Post by: ryac on August 18, 2008, 02:21:24
Hi Cliff,

Thanks for your prompt reply and answers. Things are slowly becoming more clear. Are there more examples using Flash CS3? I've seen the HelloFlash demo, there's an example that shows the mediator doing both: accessing data from the SpriteDataProxy as well as directly updating a property in the proxy. Is that right?

Ryan


Title: Re: first MVC app based on an example from AS3.0 Design Patterns
Post by: puremvc on August 18, 2008, 04:58:28
Currently the oonly other demo for CS3 is Balloonatroid, the FlashLite mobile game for AS2.

-=Cliff>


Title: Re: first MVC app based on an example from AS3.0 Design Patterns
Post by: ryac on August 18, 2008, 08:42:11
alright. thanks Cliff! :]