2 Replies Latest reply on Nov 24, 2010 7:22 AM by learner_doug

    Can I add a "mouseOver" method to a Subclass?  How?

    learner_doug Level 1

      I have the following subclass which extends TextArea.  The contentBackgroundAlpha is 0 initially.  Is is possible include mouseOver and mouseOut methods wthin this sublcass so I do not have to write the mouseOver and mouseOut handlers in the application code?

       

       

      package

      {

      import spark.components.TextArea;

       

      public class clickableText extends TextArea

      {

      public function clickableText()

      {

      super();

      setStyle("contentBackgroundAlpha", 0);

      setStyle("borderVisible", false);

      buttonMode=true;

      editable=false;

      mouseChildren=false;

      useHandCursor=true;

       

      }

      }

      }

       

      Thanks!

        • 1. Re: Can I add a "mouseOver" method to a Subclass?  How?
          BhaskerChari Level 4

          Hi doug,

           

          You can do this way...

           

          package
          {
          import spark.components.TextArea;
          public class clickableText extends TextArea
          {
            public function clickableText()
            {
             super();  
             setStyle("contentBackgroundAlpha", 0);
             setStyle("borderVisible", false);
             buttonMode=true;
             editable=false;
             mouseChildren=false;
             useHandCursor=true;
             addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
            }
            private function onMouseOver(event:MouseEvent):void
            {
             setStyle("contentBackgroundAlpha", 1);
            }
            private function onMouseOut(event:MouseEvent):void
            {
             setStyle("contentBackgroundAlpha", 0);
            }
          }
          }

           

           

          Thanks,

          Bhasker

          • 2. Re: Can I add a "mouseOver" method to a Subclass?  How?
            learner_doug Level 1

            Brilliant!

            Thank you Bhasker - this will really help reduce my code and simplify the application.

             

            Gratefully,

            Doug