Okay good people, 

I have a component I created with a list and a video player.  I use a
vstack in the application to switch between my view components like so
(for shortness I have deleted all the attributes) :

         <mx:ViewStack id="appViews" >
            <vx:HomeView id="homeView" />
            <vx:WebView id="webView" />
        <vx:ProcessView id="processView" />
            <vx:ProductView id="productView" />
            <vx:ServiceView id="serviceView" />
            <vx:CompAdvantageView id="compAdvtgView" />
            <vx:CompanyView id="compView" />
        </mx:ViewStack>

webView has the player component and on my last foray into this type
of design, I had to rely on the stack to call a method that checked if
the last view selected was the one that contained the video component,
and if it was, it called the .stop() method. That was not a very OO
type design, but it worked. I could attach a listener and do the same
thing, but still not the cleanest...

The best OO concept would be to register an event that will fire from
either the canvas that contains the component, or from the component
itself (which is an HBox) and invoke the method to stop the player
when the view stack moves away from the component or the component's
parent.  This would be the correct OO way of doing things.  Let the
component or the composite container dictate the behavior.

Before all you helpful folks starts suggesting events I can use, here
are the events listed below associated with the Canvas and HBox that I
have tried.  However, when I switch the viewstack, the video keeps on
playing (I did verify that click events worked, so the registration is
working fine).

1. deactivate - A longshot, I knew it was the meant for application
level events.

2. exitState - this looked like the money event, but NOT!

3. removedFromStage - I knew this wouldn't work.

4. resize - I have a wipedown effect that i thought might trigger
this.  Oh well...

5. hide - I didn't think so, and I was right.

I guess the other alternative is to use the ViewStack to dispatch an
event and then register that event with the component and then look at
the passed event to figure out what to do next.  I can live with that,
but it seems like the long way around the block.

Thanks,

Curtis Fisher

Reply via email to