-
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 { stage.addChild(brushDraw);
brushDraw.graphics.moveTo(mouseX, mouseY); if (active =="Brush") { brushDraw.graphics.lineStyle(brushWidth,myColor,brushOpacity); } else { brushDraw.graphics.lineStyle(eraserWidth,0xFFFFFF,eraserOpacity); }
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
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|