Change child index
package {
import flash.display.*;
public class Main extends Sprite {
public function Main( ) {
var green:Shape = createCircle( 0x00FF00, 10 );
green.x = 25;
green.y = 25;
var blue:Shape = createCircle( 0x0000FF, 20 );
blue.x = 25;
blue.y = 25;
addChild( green );
addChild( blue );
setChildIndex( blue, getChildIndex( green ) );
}
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;
}
}
}
Related examples in the same category