0 Replies Latest reply on Dec 26, 2010 6:30 PM by proyb

    getchildbyname is null

    proyb

      I have created a new sprite instance and name "Shape1" to the object, I could change the colors using mouse event but how do I simply call by name which is "shape1" so it could change automatically? I could not able to get the name of the sprite. How do I solve it?

       

      var c:UIComponent = new UIComponent();
      var s:Sprite = new Sprite();

       

          s.graphics.beginFill(0x333333);
               s.graphics.drawEllipse(7,35,18,12);
               s.graphics.endFill();
               s.name = "shape1";
                   s.addEventListener(MouseEvent.MOUSE_DOWN,chgColorBlue);
                   s.addEventListener(MouseEvent.MOUSE_UP,chgColorReset);
                   c.addChild(s);
                   }
          addElement(c);   //add object to stage
         
          private function chgColorBlue(e:MouseEvent):void {
              e.currentTarget.graphics.beginFill(0x000099);
              e.currentTarget.graphics.drawEllipse(7,35,18,12);
              e.currentTarget.graphics.endFill();
             }