A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: problem with drawing shape and setChildIndex

  1. #1
    Junior Member
    Join Date
    Jan 2011

    Unhappy problem with drawing shape and setChildIndex

    hi guys

    I'm making an android air application for school, a sketch app.
    But I'm facing an annoying problem, when I'm drawing I can draw over my bar and my menu, here's some code:

    Actionscript Code:
    function startBrushTool(e:MouseEvent):void

                    brushDraw.graphics.moveTo(mouseX, mouseY);
                    if (active =="Brush")

                    stage.addEventListener(MouseEvent.MOUSE_MOVE, drawBrushTool);

    --> so this is the function for drawing a shape on stage
    the shape is declared as

    Actionscript Code:
    public static var brushDraw:Shape = new Shape();

    now the problem is that I can draw over my menu and everything. Putting the setChildIndex of brushDraw to 1 doesn't work, it gives some error...

    anyone has an idea?

    ow yea all my objects like the menu and bar are putted on stage in the scene and are just put to visible = false in my code

    thanks guys

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Austin, TX
    Why are you putting things directly on the stage? You should put them on the root, or on descendants of the root.

    "it gives some error" tells us nothing about the actual error or what caused it.

    When you use addChild, it puts the new child on top of all other children of that parent. Ideally, you'd have your brushDraw shape added in such a way that it is below your menu and bar and other things. But that wouldn't stop you from drawing in those areas, it would just stop you from seeing the things you're drawing. You could check in the mouse_move function if the coordinates are in bounds. Or you could have a background instance and add the mouse_move listener to that instead of stage so that it only fires when you're over the drawable background.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center