Hi guys im trying to get my head around classes. Ive manged to import a class into AS3 I know it works as the trace shows but the shape im making is not showing. Heres the copde im using below. Is the this.addchild incorrect? Please help as im getting close to working this class business out. Thanks
Heres my main .as file that imports my class. As you can see ive simply draw a rectangle
And heres my other class .as file that is imported. as you can see ive simply draw another rectangle, this is not being shownCode:package classes{ import flash.display.MovieClip; import classes.bats.Leftbat; public class Main extends MovieClip{ // Variables public var net:MovieClip = new MovieClip(); public var myleftbat = new Leftbat(); public function Main(){ // net.graphics.lineStyle(1); net.graphics.beginFill(0xff0000); net.graphics.drawRect(225,0,50,400); this.addChild(net); } } }
Code:package classes.bats{ import flash.display.MovieClip; public class Leftbat extends MovieClip{ // Variables public var leftbat:MovieClip = new MovieClip(); public function Leftbat(){ // leftbat.graphics.lineStyle(1); leftbat.graphics.beginFill(0xffff00); leftbat.graphics.drawRect(0,0,50,400); this.addChild(leftbat); trace ("Hello"); } } }




Reply With Quote