I found this piece of code which apparently sets the 'z-index' of a child object, however I have a movieclip on the stage and a sprite which is being generated from the actions class. I understand they have to be within the same parent? but have no idea how to do this.
parent.setChildIndex(childObject, i)
My pie chart sprite is called into being with this function...
this.graphics.clear();
this.graphics.lineStyle(3, 0xFFFFFF);
this.graphics.beginFill(0xFF0000, 0.5);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge1start, wedge1end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge1end, wedge2end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge2end, wedge3end);
this.drawSegment(this, stage.stageWidth/2, stage.stageHeight/2, piesize, wedge3end, wedge4end);
this.graphics.endFill();
public function drawSegment(target:Sprite, x:Number, y:Number, r:Number, aStart:Number, aEnd:Number, step:Number = 1):void {
// More efficient to work in radians
var degreesPerRadian:Number = Math.PI / 180;
aStart *= degreesPerRadian;
aEnd *= degreesPerRadian;
step *= degreesPerRadian;
// Draw the segment
target.graphics.moveTo(x, y);
for (var theta:Number = aStart; theta < aEnd; theta += Math.min(step, aEnd - theta)) {
target.graphics.lineTo(x + r * Math.cos(theta), y + r * Math.sin(theta));
}
target.graphics.lineTo(x + r * Math.cos(aEnd), y + r * Math.sin(aEnd));
target.graphics.lineTo(x, y);
}
currently I just plonked my movieclip on the stage but I'm going to guess I need to call the movieclip from the actions class as well. I think I can manage that but can't figure out how to first create a parent and then call those 2 children into it.
Thanks for any help