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

Pages: [1]
Print
Author Topic: view-model connection  (Read 6810 times)
davidTikva
Jr. Member
**
Posts: 12


View Profile Email
« on: August 11, 2010, 02:28:12 »

Hey,
I'm new at PureMVC and I'm buiding a flash game.
on the screen there are characters (visual)
in the model I got a collection of CharacterVO (data)

when the user is pressing on some character, I want to show the user info about the character.
how you do it?
I need to find a way to connect visual to data.

I thought about holding an ID property in the visual class.
is that a good way?

thanks,
Dave
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: August 13, 2010, 07:20:53 »

Yes, the component should have an ID.

If the component that shows the character data is different from the character itself, one way to handle this would be:
  *  Click the character component, it sends an event,
  *  The character's mediator hears it and sends a notification with the ID in the body,
  *  A command responds to the notification, retrieves the data from the model and sends the data in the body of another notification
  *  A mediator in charge of the component used to show the character data hears the note, sets the data on its component.

Or if the character component uses the data as a tooltip, then perhaps:
  *  Clicking or hovering on the character component, it sends an event,
  *  The character's mediator hears it, retrieves the data from the model and  sets the data on its component.

-=Cliff>
Logged
Pages: [1]
Print