Mega Code Archive

 
Categories / Flash ActionScript / Development
 

AddChild( ) method doesnt guarantee that a display object is added to the display list

package {   import flash.display.*;   public class CircleExample extends Sprite {     public function CircleExample(  ) {       var red:Shape = createCircle( 0xFF0000, 10 );       red.x = 10;       red.y = 20;       var green:Shape = createCircle( 0x00FF00, 10 );       green.x = 15;       green.y = 25;       var blue:Shape = createCircle( 0x0000FF, 10 );       blue.x = 20;       blue.y = 20;              addChild( red );       addChild( blue );              addChildAt( green, 1 );     }          public function createCircle( color:uint, radius:Number ):Shape {       var shape:Shape = new Shape(  );       shape.graphics.beginFill( color );       shape.graphics.drawCircle( 0, 0, radius );       shape.graphics.endFill(  );       return shape;     }   } }