PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: davidTikva on August 11, 2010, 02:28:12



Title: view-model connection
Post by: davidTikva 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


Title: Re: view-model connection
Post by: puremvc 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>