PDA

View Full Version : Detecting Mousedown and Mouseup



nauds
November 26th, 2004, 02:02 PM
Hi, so heres what I want to do. I want to let the user control an object, in this case a cartoon character blowing a bubble. I want the user to be able to control the bubble by rapidly clicking their mouse. The faster they click the bigger it gets and when they dont click or click slowly the bubble gets smaller in size.

The only tutorial Ive found that is similar is this http://www.kirupa.com/developer/mx/gamecontrols.htm

Anyone point me in the right direction of a tutorial closer to what im trying to do? Or can anyone suggest some action scripting to use?

Thanks!

VoS
November 26th, 2004, 02:59 PM
lets say the character is a button called clickme
and the bubble is a Movie clip called bubble
then just use this code



if(bubble._xscale>100){
bubble._xscale=bubble._xscale-2;
bubble._yscale=bubble._yscale-2;
}
trace(bubble._xscale+","+bubble._yscale);
clickme.onPress = function()
{
bubble._xscale=bubble._xscale+4;
bubble._yscale=bubble._yscale+4;
trace(bubble._xscale+","+bubble._yscale);
}

put that in the 1st frame of the timeline , and have the second frame contain


gotoAndPlay(1);

nauds
November 26th, 2004, 04:43 PM
I did that, and when i export to test it, the output window pops up and spams 100,100 over and over even when im not clicking. Also the bubble does not get bigger.

VoS
November 26th, 2004, 06:10 PM
I did that, and when i export to test it, the output window pops up and spams 100,100 over and over even when im not clicking. Also the bubble does not get bigger.then you dident copy and paste it right , causs the script works
ive attached a .fla with it
good luck

nauds
November 29th, 2004, 02:40 PM
awesome it worked! thank you!

What if I wanted to put a "pop" animation at the end of it, what "if" statement would I need to set to have it pop once it reaches a certain point?

seedpod
November 29th, 2004, 04:37 PM
check if the _xscale/_yscale is over a certain number say...100. IF it is, then burst the bubble. You'd probably want to do this before allowing the bubble to deflate.

nauds
November 29th, 2004, 07:35 PM
check if the _xscale/_yscale is over a certain number say...100. IF it is, then burst the bubble. You'd probably want to do this before allowing the bubble to deflate.

Cool, what would the code for something like that look like?

nauds
November 30th, 2004, 01:35 PM
bump