开发者

Finding parent of a component in Flex

开发者 https://www.devze.com 2023-03-25 03:27 出处:网络
In my application, I took a panel and to that I added a开发者_高级运维n image by giving some image path. To that image I added DrawingArea(custom) object and started drawing. After free hand drawing I

In my application, I took a panel and to that I added a开发者_高级运维n 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);
        }

    }


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号