1 Reply Latest reply on Sep 22, 2008 1:23 PM by EvolvedDSM

    End Video when changing ViewStack

      I'm building a web site. It has a <mx:MenuBar /> across the top that has 3 buttons in it. As you click each button, they display the correct ViewStack component.

      Then, as each of these 3 ViewStack components display, they each contain a verticle <mx:LinkBar /> that displays down the left hand side of the web site. So, as you click each button at the top, you get a window that displays 5 addition buttons on the left side so you can open 5 additional windows for each of the buttons at the top.

      So basically, the 3 buttons at the top are my main ViewStack and as you click each of the 3 buttons, they open a windows that has another ViewStack that opens 5 additional windows.

      All is good so far, but here's my problem. I want to play video in each of the 5 windows. The problem comes when I change from one window to another. I can't get the video to stop playing. So, you click button 1 at the top, then on left side let's say you click the 3rd button down. The video starts. Then if you click button 3 at the top, the video keeps right on playing even though you can no longer see it because a new ViewStack window has loaded with 5 different windows you can open.

      I have a Play and Stop button for the video player and it works fine. I can even get the video to stop each time you click any of the 5 buttons on the left hand column. I did this by inserting, hide="myVid.stop();" in the first line of each the 5 components that open as you click the buttons on the left hand side. The code looks like this:

      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" clipContent="false" hide="myVid.stop();">

      So, I understand that a 'hide' event is dispatched when I switch from one component to another all within the same ViewStack and so it is easy to stop the video from playing.

      But what I DON'T understand, is how do I get this same video to stop playing when I click one of the buttons at the top of the web site. When I do that, I am no longer clicking within the same ViewStack so the hide event is not dispatched. Actually, placed the line, myVid.stop(); for every event for this component and none of them were being dispatched when I clicked from one button at the top to another.

      I'm thinking that as I click the buttons at the top, they change the entire ViewStack along the left hand side but do not modify it, so no events are actually being dispatched inside the ViewStack containing the video. If this is true, there is nothing to listen for that can be used to stop the video.

      My guess then is I have to listen for an dispatched event when the buttons at the top are clicked and then somehow determine if a video is playing in any of the other ViewStacks and turn it off that way.

      Wow. Surely, there is an easier way to do this. Any insights here? I would really appreciate an easier way of doing this.



      You can see what I'm referring to at My Marketing Site that shows what I'm trying to do
        • 1. Re: End Video when changing ViewStack
          EvolvedDSM Level 2
          I am just leaving the office, but you might want to try an evenListener, then call a function to stop your video:

          Try one of these:

          Just stick one of these into your creationComplete method and try each one until you find what it is. Create yourFunction() and have it stop the video within.