Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Tool and Canvas Architecture on: July 08, 2009, 09:28:05
I've been working through converting the beginning of a Flash/Air based application that is a simple drawing program as a test-case for developing a new larger-scale Flash/Air project on the PureMVC framework.

Now that I have spent some time running through examples and getting a pretty good understanding of the framework, I'm having a little bit of trouble trying to model out an implementation model for a ToolBar and Drawing Canvas.

The ToolBar is set up as a View/Mediator pair that sends notifications to the canvas of what the currently selected Tool is.  And the Canvas is set up to handle mouse click events and manage user input.

What I am struggling with is the best-practice approach for implementing the individual tool components and how they would properly fit into a PureMVC application.

For example.  I have a ToolBar, and the user selects the square tool.  This dispatches a notification to the Canvas to filter all user input through a Tool, and allow the Tool to direct the output that is displayed on the canvas.

Before PureMVC I would typically write a base Tool interface, which my ToolSquare would implement, having mouse down, mouse up, and mouse move handlers.  Then the ToolSquare would manage the input, run it through a series of functions to create the drawing object to be added to the canvas, and then dispatch an "AddToCanvas" CustomEvent that would pass a drawing object to the stage.

With PureMVC I would likely dispatch a CreateSquare, {properties} notification that the CanvasMediator would handle, calling the proper View functions to create the drawing object.

But what is the best practice approach for sticking a currently selected Tool within the path of the user input caught by the mediator.

Should I handle a tool as a View Component, like a Button, therefore writing a separate base class library to handle input based on the Interface?  Should the tool be a Command structure that dispatches Notifications based on input?

Am I at all on the right track here?

I'm really excited to dig into this framework and apply some more rigid and better organized development methodologies within the applications we develop here--but just like learning AS3 and the Event model, this is a definite shift in approach from how I am used to thinking.  Definitely it feels like the right direction, I'm just trying to get my habits to catch up.

Any input you folks might have on an approach to architecture here would be appreciated.

Best,

-Scott
Pages: [1]