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: How to handle ONLY ONE callout  (Read 8362 times)
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« on: March 25, 2009, 04:29:01 »

So I have a Puremvc (Single) / Flex app and in this app I have 'Callouts', which are like Google Maps callouts when you click on a marker. Just like Google Maps I only want to allow one Callout open ever. Just like Google Maps I if my app is dragged I need the Callout to follow so right now when my callout is created I addEventListener for enterframe event and then send my Callout its new coord, which are my markers new location.

All this works fine, but the issue is I cannot seem to find a clean way to remove the callout and its eventlistener when a new node is clicked.  I have a very dirty hack that more than likely breaks PureMVC best practice right now and of course it isn't stable, thus I am posting.

And no I cannot use the Flex popup, this is for several reasons that would take to long to explain.  Also to make matters worse my callout is on the main stage because it needs to be on top always and my markers are down about 4 levels in the display list.

All that being said does anyone have any suggestions on the best way to handle this?  The issue again seems to be in removing a callout and then immediately creating a new one. I have traced the issue back to UIComponents.callLaterDispatcher.  When I click a new marker I send a notification that ends up in a callout being closed, but then immediately creating a new one and UIComponent ends up storing all this in a queue that I guess is getting backup in workload. Or it could be something else. Anyway i figure via PureMVC their is a better way to do this. Would I be correct?  Maybe something like not removing the eventlistener and callout but hiding it and then just assigning it to a new marker and then turning it back on?

Though when I do want to close it manually, not by clicking another marker how would it get removed?

Hope I didn't lose you.

TIA, J
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 25, 2009, 04:35:40 »

i am a little confused, but it sounds like there needs to be a mediator for the callout and a mediator for the stage. the stage mediator would take care of removing the callout and the mediator for the callout would listen for the 'removed' message and remove its event listeners, null its reference to the callout and then remove itself.

if this doesn't make sense it's probably because I don't have a clear picture of what you're really doing, but I wanted to make a stab at it at least.
-=Cliff>
Logged
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« Reply #2 on: March 25, 2009, 07:23:43 »

Cliff, you have it correct.  The issue is that I close the callout for several different reasons, such as if the user drags the stage or zooms or clicks a home button.  I also close the callout if they click the X button to close. I also close the callout when a user clicks another marker, which is what causes issues. Since I am closing an instantly opening a new one.

I am beginning to think that it might be better to not destroy the callout, but rather hide it and then just move it to a new marker and change the VO in the calloutProxy. That way I won't have to destroy anything, but I am not sure if this is best and how I would handle the any changes in regards to the calloutMediator, if I need to at all?

Jason
Logged
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« Reply #3 on: March 26, 2009, 02:25:40 »

Cliff, So I tried what you said and I am getting this error "Error #2025: The supplied DisplayObject must be a child of the caller." when I call mainstage.removeSuperDetails();


Code in StageMediator------------------------
mainstage.removeSuperDetails();


sdc = the callout that is on stage.
Code on MainStage -------------------------
public function removeSuperDetails() : void
         {
            if(sdc)
            {
               removeStageFrameEventListener();
               this.removeChild(sdc);
               sdc = null;
               this.dispatchEvent( new Event ( NODECALLOUTCLOSED, true ) );
            }
            
         }
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: March 26, 2009, 03:55:56 »

So you have a reference to 'sdc' in your MainStage component (what is MainStage?), but is it a direct child of the component? The immediate parent must do the actual removal.

-=Cliff>
Logged
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« Reply #5 on: March 26, 2009, 08:43:04 »

mainstage is my name for the viewComponent in the stageMediator.

Sorry about the naming probably confused you. See change below.

Code on mx:Application -------------------------
public function removeSuperDetails() : void
         {
            if(sdc)
            {
               removeStageFrameEventListener();
               this.removeChild(sdc);
               sdc = null;
               this.dispatchEvent( new Event ( NODECALLOUTCLOSED, true ) );
            }
           
         }
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: March 27, 2009, 04:01:22 »

SO again, is the sdc comp a direct child of the app or is it further down the hierarchy? The immediate parent must remove it.

-=Cliff>
Logged
Pages: [1]
Print