Reputation: 543
In my application, I took a panel and to that I added an image by giving some image path. To that image I added DrawingArea(custom) object and started drawing. After free hand drawing I'm adding that to its parent(by giving this.addChild(graph);
). Here this indicates what? What can I give instead of this
(especially in case of removing a particular child)? Pardon me, if its not clear.
private function StartMarking(eve:MouseEvent):void
{
if (!eve.buttonDown)
{
isDrawing = false;
}
x2 = mouseX;
y2 = mouseY;
if (isDrawing)
{
drawColor = 0x000000;
markUp.graphics.lineStyle(2, drawColor);
markUp.graphics.moveTo(x1, y1);
markUp.graphics.lineTo(x2, y2);
drawingStr += x1 + "_"+ y1 +"_";
x1 = x2;
y1 = y2;
this.addChild(markUp);
}
}
Upvotes: 0
Views: 248
Reputation: 3395
Remove a component from its parent:
if (parent) parent.removeChild(this);
Add the direct child ("child") to the parent:
if (parent) parent.addChild(child);
The latter will remove the child from the current compenent and adds it instead to the parent of the current component so that both (current and child) are now children of the parent of the current component. Alright?
Upvotes: 2