Just a stupid question about onMouseDown

It’s probably something stupid but I’m having problems with calling a function triggered by onMouseDown.

My code:


_root.myMC.onMouseDown = function() {
	_root.x = _root._xmouse;
	_root.y = _root._ymouse;
	startDrawing(270,75,x,y);
}

The idea is that the function ‘startDrawing’ only has to execute when I click on the mc ‘myMC’ which contains a (filled) square, a sort of a drawingboard.
However, it also executes when I click anywhere else in my movie.

How come?? Am I losing it?

This may work, but I haven’t tested it.
:-\

_root.myMC.onMouseDown = function() {
_root.x = _root.myMc._xmouse;
_root.y = _root.myMc._ymouse;
startDrawing(270,75,x,y);
}

I think you have to specify the mouse position on the movie clip in question.

onMouseDown is a global mouse down detection. onPress is a click on the button/movieclip only mouse down detection. You might want to use that instead (and maybe use _root.myMC.useHandCursor = false if you dont want the hand cursor). If that wont work for you, for instance, in the case where you have other buttons within the movieclip which are then disabled as the movieclips onPress overrides them, then you can use onMouseDown with hitTest on the mouse to 1) check when the mouse is pressed and 2) check if, when the mouse is pressed, the mouse is over (hitTest true) the current movieclip. If so, then execute the desired code.

Thanks a lot Senocular, the onPress indeed did the trick.

And about the hitTest: I don’t have buttons or anything in the mc so that’s not necessary. But thanks for the detailed explanation.

Cheers,

FlashMataZZ