as3 this.graphics calls do nothing

Posted by zzz on Stack Overflow See other posts from Stack Overflow or by zzz
Published on 2011-01-01T17:39:32Z Indexed on 2011/01/01 22:53 UTC
Read the original article Hit count: 202

Filed under:

class A:

[SWF(width='800',height='600',frameRate='24')]
public class A extends MovieClip {
   private var b:B;
   public function A(){
     super();
     b = new B();
     addChild(b);
     addEventListener(Event.ENTER_FRAME, update);
   }
   private function update(e:Event):void {
     b.draw();
   }
}

class B:

public class B extends MovieClip {
    public function draw():void {
       //! following code works well if put in constructor, but not here
       this.graphics.beginFill(0xff0000);
       this.graphics.drawCircle(200,200,50);
    }
}

this.graphics calls do nothing in draw method, but work fine inside B`s constructor, what i am doing wrong ?

© Stack Overflow or respective owner

Related posts about actionscript-3