I’m new to as3 and I’m trying to write a class that has to draw something.. I can’t quite figure out how you put up the code?
player/Player.as:
package player {
import flash.display.Sprite;
public class Player extends Sprite {
public var loader = null;
public function Player(){
this.cnstr_loader();
}
private function cnstr_loader(){
this.loader = new Sprite();
addChild(this.loader);
this.loader.graphics.lineStyle(1,0x000000);
this.loader.graphics.beginFill(0x0000FF);
this.loader.graphics.drawRect(0,0,10,10);
this.loader.graphics.endFill();
this.loader.x = 10;
this.loader.y = 10;
trace('e');
}
}
}
main.as:
import player.Player;
var _Player = new Player();
how can you draw the whole Player class in its own movieclip or sprite or what its called?
addChildis what you are looking for. You should also read about the DisplayList