stage是文档类的父对象
一个fla文档类里代码:
var mySprite:Shape=createRec(); var myMC:Shape=createRec(0xffcc00,40,20,4); var myShape:Shape=createRec(); this.stage.addChild(mySprite); this.addChild(myMC); myMC.x=100; this.addChild(myShape); myShape.y=100; //2 trace(this.parent.numChildren); //true trace(this.stage==this.parent); function createRec(col:uint=0x00ff00,width:int=20,height:int=20,cornerRadius:int=5):Shape { var shape:Shape=new Shape(); shape.graphics.beginFill(col); shape.graphics.lineStyle(1,0xff0000); shape.graphics.drawRoundRect(0,0,width,height,cornerRadius); shape.graphics.endFill(); return shape; } |