PDA

View Full Version : onMouseDown fires at the worng time...


msodrew
03-21-2007, 11:39 PM
Please excuse the ridiculous misspelling of "wrong" in the title.... haha.

Hey people perhaps you could lend me some help.

I've got a container_mc that holds two things:

a picture of a polaroid (as decoration)
a dynamically loaded image offset into the polaroid to fit


I want different things to happen for clicking on the two different children mc's! I've got the two different definitions as like
container_mc.pic.onMouseDown = function () { /* some action */ };
container_mc.polaroid.onMouseDown = function () { /* some action */ };

The problem is that when i click a part that is DEFINITELY the polaroid, it registers it as a click for the pic MC! Oh noes.:o

Can anyone help?

Some notes: the pic mc was made via createEmptyMovieClip then using a MovieClipLoader object to load the jpg into it. The polaroid mc is BELOW the pic as far as depth (which should be obvious or else you wouldn't see the pic).

Thanks.

straydog
03-21-2007, 11:56 PM
sounds like when you dymnamically created the MC for the jpg the MC was made larger than the MC for the polaroid background. And becasue you have the jpg MC above the polaroid MC it registers a click on the jpg MC.

try making a third MC to house both jpg MC and polaroid MC so you can put both the jpg MC and the polaroid MC on the same level and or in the same frame.

hope that helps some.

msodrew
03-22-2007, 12:13 AM
try making a third MC to house both jpg MC and polaroid MC so you can put both the jpg MC and the polaroid MC on the same level and or in the same frame.

I don't understand what this 3rd MC would accomplish... If the tree ends up being like
container_mc -> extra_mc -> pic_mc (depth 1)
\-----> polaroid_mc (depth 0)

then whats the difference?

jsonchiu
03-22-2007, 12:50 AM
replace onMouseDown() with onRelease() or onPress()!
container_mc.pic.onRelease = function () { /* some action */ };
container_mc.polaroid.onRelease = function () { /* some action */ };

msodrew
03-22-2007, 01:04 AM
replace onMouseDown() with onRelease() or onPress()!

how could that possibly make a difference?

jsonchiu
03-22-2007, 01:13 AM
.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.

msodrew
03-22-2007, 01:18 AM
.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.

I tried both onRelease and onPress and they simply never fire. Eh... im lost.

reyco1
03-22-2007, 03:51 AM
omPress or onRelease should have definitely worked... hmmm,,, could you post your fla or recreate it in a new fla and post that?

straydog
03-22-2007, 04:16 AM
I don't understand what this 3rd MC would accomplish... If the tree ends up being like
container_mc -> extra_mc -> pic_mc (depth 1)
\-----> polaroid_mc (depth 0)

then whats the difference?


the 3rd MC acts as a container for both of the other 2 MCs allowing both polaroid MC and jpg MC to be at the same depth level

3pepe3
03-22-2007, 09:03 AM
.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.
this is the best way and it must work... but it's not going to work if you have something like onRelease, onRollOver, etc in the container_mc


container_mc.pic.onMouseDown = function () {
if (this.hitTest(_root._xmouse,_root._ymouse,true)){
/* some action */ }
};
container_mc.polaroid.onMouseDown = function () {
if (this.hitTest(_root._xmouse,_root._ymouse,true)){
/* some action */
}
};
///or use this:
/*
this.onMouseDown = function () {
if (container_mc.pic.hitTest(_xmouse,_ymouse,true)){
/* some action */
}
if (container_mc.polaroid.hitTest(_xmouse,_ymouse,tru e)){
/* some action */
}
}*/


or more easy... if you have some mouse handler on the container_mc change it to some global mouse behavior.
if you have something like
container_mc.onRollOver()=function(){/*///blablabla///*/}
change it for :

container_mc.onMouseMove = function () {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
inside = true;
mover();
}
if (!this.hitTest(_root._xmouse, _root._ymouse, true) && inside == true) {
inside = false;
moverOut();
}
};
///and then you are going to be more free to work inside this movieClip
container_mc.pic.onRelease = function () { /* some action */ };
container_mc.polaroid.onRelease = function () { /* some action */ };