4 Replies Latest reply on Feb 3, 2009 5:59 PM by Clifford Meece

    changing button skin state from AS

    Clifford Meece
      Hi, I developed a custom programmatic button skin with various effects for upSkin, overSkin, and downSkin. Now I'd like the 'overSkin' skin to appear when a separate (parent container) is hovered over. Is this possible to do in actionscript?

      To be clear, I have a custom component derived from canvas that has several children components, like a textInput and my custom button. I would like my button to show it's overSkin when it is hovered over(that works) and also when the parent canvas and textInput are hovered over.

      Thanks in advance,
      Cliff
        • 1. Re: changing button skin state from AS
          -Hob Level 1
          You could try manually dispatching a MouseEvent.MOUSE_OVER event from the button. That will likely trigger it. (if not, try MouseEvent.ROLL_OVER).
          • 2. Re: changing button skin state from AS
            Clifford Meece Level 1
            thanks, yes, that may work....sorry to be a newbie, but can you give me a pointer on how to manually dispatch an event?

            thanks,
            • 3. Re: changing button skin state from AS
              -Hob Level 1
              It's easy. Just do something like:

              myButton.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER));

              That simulates the event of a user passing their mouse over the button.
              • 4. Re: changing button skin state from AS
                Clifford Meece Level 1
                thanks for the help.

                It turns out that MOUSE_OVER didn't work, because the button is a child and this started an infinite loop. I thought setting bubble to false would fix it but no luck.

                Using ROLL_OVER worked though. I also hadd to add a MOUSE_OUT handler. So it ended up looking like this:

                <...>

                addEventListener(MouseEvent.MOUSE_OVER, nodeMouseOverHandler);
                addEventListener(MouseEvent.MOUSE_OUT, nodeMouseOutHandler);


                private function nodeMouseOverHandler (event:MouseEvent):void
                {
                //trace("hovering node");
                var result:Boolean = addButton.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OVER, false));

                }
                private function nodeMouseOutHandler (event:MouseEvent):void
                {
                //trace("hovering node");
                var result:Boolean = addButton.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OUT, false));
                }