0 Replies Latest reply on Dec 13, 2010 10:32 AM by thenewmexican62

    Rounded Image,mouseUp/Down effects, and event problem

    thenewmexican62 Level 1

      I'm using the RoundedImage AS3 code found on-line pretty much everywhere.
      When applying mouseUpEffect/mouseDownEffect(s) with a RoundedImage instance,
      the event dispatching for RoundedImage instances in question becomes erroneous.
      The first RoundedImage instance declared, functions as expected, dispatching both mouseUp, and mouseDown events.
      However, the second RoundedImage instance declared, only responds to the mouseDown event. The mouseUp event gets lost.

       

      Any help is greatly appreciate it.

       

      Here is the code for the RoundedImage.as

       

      public class RoundedImage extends Image {
             
              public function RoundedImage(){
             
                  super();
              }
             
              public function get cornerRadius():int {
                  return cornerRad;
              }
             
              public function set cornerRadius(radius:int):void {
                  cornerRad = radius;
              }
             
              override protected function createChildren():void {
                 
                  super.createChildren();
                 
                  this.roundedMask = new UIComponent();
                  this.addChild(roundedMask);
              }
             
              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                 
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
                 
                  roundedMask.graphics.clear();
                  roundedMask.graphics.beginFill(0x000000);
                  roundedMask.graphics.drawRoundRectComplex(0, 0, unscaledWidth, unscaledHeight,cornerRad, cornerRad,cornerRad, cornerRad);
                  roundedMask.graphics.endFill();
                 
                  this.mask = roundedMask;
              }
             
             
              protected var roundedMask:UIComponent;
              protected var cornerRad:int;
             
          }
      }

       

        private function testMouseClick(event:Event):void {
                     
                      trace("inside testMouseClick");
                     
         }

       

      <RoundedImage x="0" y="10" id="roundedImage1" click="testMouseClick(event)" mouseUpEffect="{unglowRoundedImage1}" cornerRadius="25" mouseDownEffect="{glowRoundedImage1}" source="{icon1}"  width="75" height="75"/>
      <RoundedImage x="100" y="10" click="testMouseClick(event)" id="roundedImage2" mouseUpEffect="{unglowRoundedImage2}" cornerRadius="25" mouseDownEffect="{glowRoundedImage2}" source="{icon2}" width="75" height="75" />