RE: [Flashcoders] Seek MVC Menu
Thankx for the overview Michael...I'm really hoping to find a fleshed out, workable version I can tear apart. I suppose it wouldn't have to be a menu per se...but it sure seems like a creature such as this would have been tutorialized. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Sunday, December 17, 2006 5:21 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Seek MVC Menu On 12/17/06, Stephen Hueners [EMAIL PROTECTED] wrote: Seems like the MVC pattern would be a natural fit for a menuing system that has to keep track of things like logged user various button states and actions. I'm looking for a sample of AS2 code being used to build a menuing system. Kind of depends on what your states and actions are. Here's a good basis: /** * Model class that stores data for one menu item. f * * pOptionally has child items./p */ class menu.MenuItem { /** * Label for this item. */ public function get label():String; /** * Number if child items (nonnegative integer). */ public function get childCount():Number; /** * Retrieves a child item. * * @param index Index of child item, nonnegative integer less than [EMAIL PROTECTED] #childCount}. */ public function getChild(index:Number):MenuItem; /** * Reads data from an XML node. * * @param node XML node with menu item data. * @throws Error If [EMAIL PROTECTED] node} is not properly formatted. */ public function readXMLNode(node:XMLNode):Void; } import menu.MenuItem; import mx.events.EventDispatcher; [Event(currentChange)] /** * Controller class that keeps track of the currently-selected item. */ class MenuController extends EventDispatcher { /** * Currently-selected menu item. */ [Bindable(event=currentChange)] public function get currentItem():MenuItem; public function set currentItem(item:MenuItem):Void; } import menu.MenuController; import menu.MenuItem; /** * Menu item component. */ class menu.MenuItemView extends MovieClip { /** * Creates a new instance referring to a specific item. * * @param parent Parent movie clip. * @param controller Object that controls the menu. * @param item Menu item model object. * @return New instance of this class. */ public static function create(parent:MovieClip, controller:MenuController, item:MenuItem):MenuItemView; /** * The item that this component refers to. */ public function get item():MenuItem; } MenuView components could then listen to MenuController.instance for currentChange events and update whether or not they are enabled or disabled. Further attributes could be added to MenuItem (id, type, selectable, whatever). MenuController could also be used to keep track of other things. It might also be a good idea to create a Menu class for containing top-level MenuItem objects, with a corresponding MenuView class for containing top-level MenuItemView object. There are a lot of different things you could do with this basic MVC setup, depending on what you need. -- T. Michael Keesey The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Seek MVC Menu
On 12/18/06, Stephen Hueners [EMAIL PROTECTED] wrote: Thankx for the overview Michael...I'm really hoping to find a fleshed out, workable version I can tear apart. How about mx.controls.Menu? I suppose it wouldn't have to be a menu per se...but it sure seems like a creature such as this would have been tutorialized. Well, as long as you understand: - private variables, and how they may be used as a basis for properties; - using the XMLNode class; - the event dispatcher model, and the MX implementation thereof; - static vs. instance functions; - and symbol registration; ... you should be able to use the skeleton I outlined in my previous post. If you're not familiar with one of them, I'd look for a tutorial on that. -- T. Michael Keesey The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Seek MVC Menu
On 12/17/06, Stephen Hueners [EMAIL PROTECTED] wrote: Seems like the MVC pattern would be a natural fit for a menuing system that has to keep track of things like logged user various button states and actions. I'm looking for a sample of AS2 code being used to build a menuing system. Kind of depends on what your states and actions are. Here's a good basis: /** * Model class that stores data for one menu item. f * * pOptionally has child items./p */ class menu.MenuItem { /** * Label for this item. */ public function get label():String; /** * Number if child items (nonnegative integer). */ public function get childCount():Number; /** * Retrieves a child item. * * @param index Index of child item, nonnegative integer less than [EMAIL PROTECTED] #childCount}. */ public function getChild(index:Number):MenuItem; /** * Reads data from an XML node. * * @param node XML node with menu item data. * @throws Error If [EMAIL PROTECTED] node} is not properly formatted. */ public function readXMLNode(node:XMLNode):Void; } import menu.MenuItem; import mx.events.EventDispatcher; [Event(currentChange)] /** * Controller class that keeps track of the currently-selected item. */ class MenuController extends EventDispatcher { /** * Currently-selected menu item. */ [Bindable(event=currentChange)] public function get currentItem():MenuItem; public function set currentItem(item:MenuItem):Void; } import menu.MenuController; import menu.MenuItem; /** * Menu item component. */ class menu.MenuItemView extends MovieClip { /** * Creates a new instance referring to a specific item. * * @param parent Parent movie clip. * @param controller Object that controls the menu. * @param item Menu item model object. * @return New instance of this class. */ public static function create(parent:MovieClip, controller:MenuController, item:MenuItem):MenuItemView; /** * The item that this component refers to. */ public function get item():MenuItem; } MenuView components could then listen to MenuController.instance for currentChange events and update whether or not they are enabled or disabled. Further attributes could be added to MenuItem (id, type, selectable, whatever). MenuController could also be used to keep track of other things. It might also be a good idea to create a Menu class for containing top-level MenuItem objects, with a corresponding MenuView class for containing top-level MenuItemView object. There are a lot of different things you could do with this basic MVC setup, depending on what you need. -- T. Michael Keesey The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com