Question

I want to create an invisible drawing surface that sits over top of an image. This drawing surface would be in charge of taking mouse input and passing the coordinates along to a sprite that sits on the layer between the drawing surface and the image. The drawing surface is an empty Sprite.

According to the docs, a display object that has nothing inside it cannot have its width or height set. That is, it will always be zero.

Is there any way around this? What is the best practice?

Was it helpful?

Solution

You can work with the drawing api to draw shapes with extremely low alpha values, this will give you the values without being visible to the eye.

BUT

Perhaps a better solution would be to register your mouse listeners on the stage from within the drawing surface sprite, and have it handle the mouse events on it's own. I don't know enough about what you are trying to do, but if possible, it would be a cleaner / simpler solution.

Even if you can't put the listeners in the drawing surface sprite, you should be able to add them to the stage from where ever you are working, rather than using an extra object.

OTHER TIPS

If you only need the limits for your drawing, I think the easiest solution would be listening for the stage mouse events, and programaticaly limit your drawing... If you still think you need that transparent sprite, you can draw a transparent rectangle (beginFill(0, 0)) or create a transparent bitmap (new BitmapData(width,height,true,0)). Not sure which would be the "best practice"....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top