3 Replies Latest reply on Jul 12, 2008 7:43 PM by strayhand

    Help manipulating buttons

      I'm using the setInterval method to cycle through a set of images within a ViewStack every six seconds. That part seems to be working correctly. I've also got some buttons off to the side that manipulate the selectedIndex of the ViewStack. Here's my problem:

      I can't seem to manipulate the button states to correspond with the current ViewStack image. I'm going nutz trying to manipulate these buttons and none of my searches seem to yield what I'm looking for. I want the buttons to appear as if the user has moused over them when the corresponding ViewStack image is shown. How can I do that?

      Here's my Zipped Flex Project

      And here's another look at my code. Thanks.
        • 1. Re: Help manipulating buttons
          Gregory Lafrance Level 6
          Look for my use of the show and hide events to dispatch Button MOUSE_OVER and MOUSE_OUT events. Don't forget the one for the ViewStack.
          • 2. Re: Help manipulating buttons
            strayhand Level 1

            Thanks for the reply and the code. I was able to hack something together that comes close but I've run into other issues as a result of this approach. Basically it boils down to this:

            - I want the ViewStack to cycle through the images automatically (check)
            - I want the button states to correspond to the current ViewStack image (check)
            - I want to rollover the buttons and update the ViewStack (check)
            - When I rollover a button I want the automatic rotating of the ViewStack to stop. THIS IS WHERE I'M RUNNING INTO ISSUES.

            SOLUTION 1 (Didn't pan out). Call methods for starting or stopping the ViewStack rotation from the button events.

            I wrote some new methods for stopping and starting the setInterval method so that the ViewStack would stop cycling through. But I think that I have scope problem or something because it wouldn't work correctly. I think that the stopInterval method was clearing the global variable that I setup, but that it was unable to clear the local variable within the startInterval method. This doesn't make a lot of sense to me, but I think that's what's going on.

            SOLUTION 2 (Didn't pan out). Use a boolean check within the advancePlayer method (Cycles stack). IF the boolean is set to false keep cycling otherwise don't update the ViewStack.

            The boolean is a global variable that I tried to manipulate using rollover and rollout events attached to the VBOX which contains all of the buttons. This didn't work either. Apparently the rollover and rollout events get triggered when ever the child button rollover/rollout events get triggered.

            SOLUTION 3. Keep track of the mouse position if it's over the VBOX container then do not update the ViewStack.

            This is similar to solution 2, only I'm hoping that the mouse position will be independent of the VBOX/BUTTON mouse events. I know where the VBOX is positioned, I just don't know enough about actionscript to keep tabs on the mouse position.

            Got any suggestions? I've posted my revised code and you can look at it below as well. Thanks.
            • 3. Re: Help manipulating buttons
              strayhand Level 1
              To anyone looking for the answer to this. Greg points out how to use the dispatchEvent() method to trigger new MouseEvents. You can read more about my project here, where I eventually figure out how to integrate buttons and viewstacks. Thanks.