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]
Author Topic: Continous x,y coordinates from multiple sprites  (Read 8368 times)
Courseware Beta
Sr. Member
Posts: 50

View Profile Email
« on: March 09, 2009, 08:33:53 »

So, I have this Flex project where I am creating popups on the main stage for several sprites on the display list. So if you click a sprite it opens a new popup.  The issue is the sprites move so I need the popups to move also.

And no I can't put the popups in the sprite because sprite isn't high enough on the hierarchy so it isn't an option.  So I have SpriteMediators for each sprite and a popupmediator for each popup.

What I am thinking of doing is having the sprite dispatch continous events that contain the x,y of the sprite. Then have the spritemediator convert those events to notifications.  Then have the popupmediators receive those notifications and alter the popup accordingly.  The issue is how can I tell which spritenotification goes with which popupmediator?

Maybe this is the totally wrong structure?  I am not using the multicore and I can't switch to that as I have a deadline in two days.  If multicore is the best way to go I can switch it later, but I need a temporary fix for now.
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: March 12, 2009, 06:02:45 »

You're fine with the Standard version and your event to note approach will work. 
Presumably these Sprite and Popup Mediators are dynamically named. So tie the two mediator names together with a common postfix, such as 'SpriteMediator-12' and PopupMediator-12' 

When the SpriteMediator sends a note to the PopupMediator, have it pass its name as the type parameter like: sendNotification(ApplicationFacade.SPRITE_MOVE, point, this.getMediatorName())

Then have a parsing function in the PopupMediator that returns the postfix from a string.

And in the PopupMediator's handleNotification switch, in the case for note.getName == SPRITE_MOVE, check the postfix before acting like: if (getPostfix(note.getType()) ==  getPostfix(this.getMediatorName()) { // update popup coords from Point passed in note body}

Hope this gets you to the finish line :)

Pages: [1]