2 Replies Latest reply on Jun 5, 2010 7:44 AM by SiHoop

    How do I ignore a rollover on text object?

    SiHoop Level 1

      The following code builds a custom button. It has a bug. The hand cursor becomes a mouse pointer and the rollout state is activated when I roll over the overlapping Label:

      1. How can I ignore a rollover on the Label?.

      2. How can I make the hand cursor  remain in place while I roll over any part of the HBox (including the Label)?

       

      Thank you!

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"   buttonMode="true"
          useHandCursor="true">
      <mx:Script>
          <![CDATA[
      import mx.events.FlexEvent;
      [Bindable]        public var buttonTitle:String;
          public function init():void{
              hbox.width=textField1.width;
              hbox.height=40;
              fillDark()
              hbox.addEventListener(MouseEvent.MOUSE_OVER, handleRollOver)
              hbox.addEventListener(MouseEvent.MOUSE_OUT, handleRollOut)
          }
          private function handleRollOver(e:MouseEvent):void{
              fillLight();
              textField1.styleName="sectionsButtonOver";
          }
          private function handleRollOut(e:MouseEvent):void{
              fillDark();
              textField1.styleName="sectionsButton";
          }
          private function fillDark():void{
              hbox.graphics.beginFill(0x2b2b2b)   
              hbox.graphics.drawRect(0,0,this.width-1,40)
              hbox.graphics.endFill()
              hbox.graphics.beginFill(0x414141)   
              hbox.graphics.drawRect(this.width-1,0,1,40)
              hbox.graphics.endFill()
          }
          private function fillLight():void{
              hbox.graphics.beginFill(0x3f3f3f)   
              hbox.graphics.drawRect(0,0,this.width-1,40)
              hbox.graphics.endFill()
              hbox.graphics.beginFill(0x414141)   
              hbox.graphics.drawRect(this.width-1,0,1,40)
              hbox.graphics.endFill()
          }
          ]]>
      </mx:Script>

       

      <mx:HBox id="hbox" buttonMode="true" useHandCursor="true" />

      <mx:Label id="textField1" text="{buttonTitle}"  y="13" selectable="false"  buttonMode="true" useHandCursor="true"
           styleName="sectionsButton"  />
          
      </mx:Canvas>