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 / General Discussion / Timer and Proxy on: November 22, 2009, 01:16:49
Hello coders  :)

I have a requirement where a timer is ran in the background of my app.
Every minutes it makes an http call to a web server.

In case of a particular state in my app: when at least two users are connected to my session i should make a different http call and increment a clock counter (every second) of a ViewComponent.

At the beginning i started doing the ticking in a clockMediator calling the proxy when needed and updating the view as well.

Should i instead have the the timer and counting of "total seconds" and "total seconds with multi users" in the proxy ? Emitting a notification every seconds when multi user condition is true ?.

Thanks for your wise advices,

Greg


2  Announcements and General Discussion / General Discussion / Board Architecture, refactoring and planning on: November 11, 2009, 12:02:50
Greetings Architects  ;D

I want to re-factorise some of my code (edoboard.com) as i am starting to feel the need for a better architecture and i realised i was doing many things badly even within the boundaries PureMVC (mixing mediator and proxy roles, not enough commands and so on.

Here is a simplified diagram of the current classes.
http://i34.tinypic.com/24fxuft.png



On the view side i have Tabs, each Tab holding a Canvas where i can draw and manipulate shapes.

Therefore we have a BoardManagerMediator handling the following actions: close tab, add tab, duplicate tab. It also keeps reference to a proxy called BoardManagerProxy.

BoardManagerProxy keeps a list of BoardMediators (one boardMediator = one tab).
It also have attributes like 'currentBoardMediator' 'currentShape' 'selectedShapes' ...

1.Is it the good place to hold these  ?
2.What about the naming, does it make sense ?

Shapes

When i add a shape the BoardMediator i s responsible for listening to the mouse down / move / up events. It looks in a toolbarProxy to see the current selected shape and starts drawing it on mouse down.

That is just  the instantiation of a Circle Shape and resizing its width/height on mouse move until a mouse up.

On mouse up the boardMediator pushes the shape to Shape list boardProxy, and send a Notification (with the new shape as the body) to the BoardManagerMediator.

The boardManagerMediator update the current Shape attribute on its boardManagerProxy. The shapeid counter (boardManagerProxy) is also incremented.

3. I definitely forgot a lot of things but is there any big architecture flaws so far ?

Each Shape needs a mediator and a Model (proxy) ?.

Sample of a simpleShapeModel

:

package com.roguedevelopment.objecthandles.example
{
import com.roguedevelopment.objecthandles.IMoveable;
import com.roguedevelopment.objecthandles.IResizeable;

public class SimpleDataModel implements IResizeable, IMoveable
{
[Bindable] public var x:Number = 10;
[Bindable] public var y:Number  = 10;
[Bindable] public var height:Number = 50;
[Bindable] public var width:Number = 50;
[Bindable] public var rotation:Number = 0;
}
}

Should the proxy hold the model ? Or should the model be also a proxy ?

Actually i need a minimalist mediator since all rotation/move stuff are handled by an external library (objecthandle).

My mediator will just keep a reference to the model and offers functions like update fill color, opacity etc. These functions will be called by the boardMediator. we do not want all shapes to listen for the update color notification and check if its for them.

So at the end my boardProxy will hold a list of ShapeMediator ?


Multi selection

I want to redo my multi selection to handle ctrl key to remove a shape from a selection and shift to add one. I was going to do it from the shape mediator.


The shape know when it receives a mouse down event with ctrl/shift key activated. That means all shapes listen for ctrl/shift key ?

It then fires an event like 'add_to_selection_group' which is catch by the boardMediator. The boardMediator send a addShapeToGroupCommand

Maybe it is at the boardMediatorManager level that we should look for the ctrl/shift key ?

Anyway our addShapeToGroupCommand will get a hand on the currentBoardMediator from boardManagerProxy and manipulate it to redraw the selection area, and update the boardManagerMediator proxy selectedShapes attribute.

That is way too long and maybe not very intelligible, but i have no occasion to share these design questions :)

Looking to have some good design i can be happy to look at.

Thanks !

Greg

3  Announcements and General Discussion / General Discussion / Use case shift key state and mediators on: November 09, 2009, 03:05:28
Hello Pure Flexers,

I wanted to share a small design question i am on.
I have several mediators who need to know the state of shift key (stage) at a given time.

For now each mediator was listening for key down event and updating a local boolean isShiftKeyActive.
Each mediator also have their own proxy.
I was thinking of adding a sharedProxy unique for all mediators which will have other properties and actions than a shift key state holder.

What do you think ?  ???
4  Announcements and General Discussion / Public Demos, Tools and Applications / Edoboard advance whiteboard for Math: PureMVC AFCS Degrafa on: June 18, 2009, 07:19:02
Hi there,

About 10 months after i came around here starting to learn as3 and PureMVC, we finally have something to show.

Edoboard is an education oriented collaborative platform, especially useful for tutoring Math online.

It uses PureMVC single Core (multi core on the todo list for better modularity), AFCS for collaboration between users actions and Degrafa for shapes and skinning.

There are still a lot of thing to improve and some architecture to refactorise, but PureMVC really helped me in organizing the code.

I am open to any critics and suggestions.

Quick Walk through: http://www.youtube.com/watch?v=PTLpVFuWq7A

You can test it online by clicking "test" on http://www.edoboard.com


Cheers, :)

5  Announcements and General Discussion / General Discussion / PopupManager, and recurring popup, design question on: March 11, 2009, 11:22:17
Hi all,

I saw a topic on using a PopupManager with static methods to close and create popup given its Component CLass and MediatorClass.
In my case i have a popup that a user can call then close then call again ect.., this popup is kind of expensive to instantiate so for now i was just "hiding it" and keeping only one mediator handling the hide unhide.
But that is uncompatible with the popup manager way of doing things.

How would you handle such Popups ?

Thanks a lot

Greg
6  Announcements and General Discussion / Architecture / Mediator with multiple views, toolbar stack ? on: November 25, 2008, 04:40:16
Hi guys,

I am facing a design problem i havent encountered before.

I have a BoardView with a boardMediator
a boardToolbarView with boardToolbarMediator, the toolbar it a tile of several Shapes.

Each Shape should be associated to a toolbar for its type (rectangle, circle, etc).

Instead of creating a RectangeToolbarMediator, CircleToolbarMediator etc ...
for each type can i create just one ShapeToolbarMediator registering several views CircleToolbarView, RectangeToolbarView etc.


Then when my boardToolMediator send a toolchange notification, ShapeToolbarMediator will listen for it and display the appropriate shapeToolbarView.

How would you do such a thing ?

-------------------
|                      H |     H: boardToolBar
|                      H |     x: shapeToolBar
|             xxx     H |
-------------------

Thanks


7  Announcements and General Discussion / General Discussion / CoCoMo and PureMVC advices needed on: November 21, 2008, 03:12:24
Hi guys,

I was building a collaborative project using PureMVC, now i see that CoCoMo is knocking at the door and it will simplify a lot of work if we use it for our project.

The thing i dont know is how to integrate PureMVC with it.

Looking a this simple chat code coming from CoCoMo examples

:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:rtc="CocomoNameSpace">

<mx:Script>
<![CDATA[
import com.adobe.rtc.pods.simpleChatClasses.ChatMessageDescriptor;
import com.adobe.rtc.events.ChatEvent;
import com.adobe.rtc.pods.simpleChatClasses.SimpleChatModel;

// This simple example just shows how this shared model can be made easily bindable for MXML.
// See SimpleChatModel for details.

[Bindable]
public var chatModel:SimpleChatModel;
protected function buildModel():void
{
// Create the model: just calling the constructor won't create the collection node or pass the messages.
// Call subscribe and give it a shared ID while creating the model.
// The shared ID becomes the name of the collection node.
chatModel = new SimpleChatModel();
chatModel.sharedID = "myChat_SimpleChatModel";

chatModel.subscribe();
chatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
this.addEventListener(KeyboardEvent.KEY_UP, onKeyStroke);
}

protected function submitChat(str:String):void
{
var cmd:ChatMessageDescriptor = new ChatMessageDescriptor();
cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
cmd.msg =  str;
chatModel.sendMessage(cmd);
chat_mesg_input.text = "";
}

protected function clearChat():void
{
chat_mesg_area.text = "";
chatModel.clear();
}

protected function onChatMsg(p_evt:ChatEvent):void
{
if(p_evt.message != null && p_evt.message.msg != null && p_evt.message.displayName != null)
chat_mesg_area.text += "\r\n" +  p_evt.message.displayName + ": " + p_evt.message.msg;
else
chat_mesg_area.text = "";
}

protected function onKeyStroke(p_evt:KeyboardEvent):void
{
if(p_evt.keyCode == Keyboard.ENTER) {
submitChat(chat_mesg_input.text);
}
}

]]>
</mx:Script>


<!--
You would likely use external authentication here for a deployed application;
you would certainly not hard code Adobe IDs here.
-->
<rtc:AdobeHSAuthenticator
id="auth"
userName="AdobeIDusername"
password="AdobeIDpassword"  />

<rtc:ConnectSessionContainer roomURL="YourPersonalRoomUrl" id="cSession" authenticator="{auth}" width="100%" height="100%">
<mx:Canvas width="100%" height="100%" creationComplete="buildModel()">
<mx:VBox id="chatBox">
<mx:TextArea width="800" height="500" id="chat_mesg_area"/>
<mx:TextInput width="400" id="chat_mesg_input"/>
<mx:HBox>
<mx:Button label="Submit Chat" click="submitChat(chat_mesg_input.text)"/>
<mx:Button label="Clear Chat" click="clearChat()"/>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
</rtc:ConnectSessionContainer>
</mx:Application>


What would be the convertion path to a PureMVC way

Myapp.xml will sendNotification( STARTUP, app );
Which call StartupCommand

Which registers Proxies: what are my proxies here ?
ConnectSessionContainer  give access to many stuff:
    authenticator : AbstractAuthenticator
    autoLogin : Boolean = true
    fileManager : FileManager
    initialRoomSettings : RoomSettings
    isSynchronized : Boolean
    roomManager : RoomManager
    roomURL : String
    streamManager : StreamManager

What would be his place in PureMVC ?



ChatMessageDescriptor is a "simple value-object to describe chat message properties."  where should i put it ? in a descriptor folder along my models ?

cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;

chatModel will be in a ChatProxy as a VO ?

Since here the View talk to the ChatModel directly with bindable there is no mediator. Should i add one ?

Thanks for your answers i want to continue using PureMVC.  :D




8  Announcements and General Discussion / General Discussion / Concept Question, proxy and vo for a chat on: October 12, 2008, 03:20:39
Hi,

Firstly thank you for creating such a framework it forces good practices and unless you are a Pattern/OO wizard we need it !

I am new to AS3/Flex/pureMVC, in order to test my understanding of the framework i am trying to build yet an other chat with Flex/FMS and server side shared objects.

Please tell me if there is anything wrong in the following facts:
Simple case its a 1-1 chat.

- I dont need to store the messages received and typed in a messagesVO as an arrayCollection of String, i will just update the text widget of my Chat View Component by cummulating the chatmessage string attached to a notification sent by the proxy?

- I need a ChatProxy which will be an async remote proxy interfacing the remote shared object ?

- In a pureMVC jabber Chat demo around the author uses a custom chatEvent holding an id and a string, is there a need for custom events when we can pass Array as notification body. I guess there is an obvious use for it, but an example may be welcome.

PS:
If somehow i manage to build this small app after review i will add it to the contributions.

Thanks,
Pages: [1]