all groups > flash actionscript > january 2004 >
You're in the

flash actionscript

group:

double click button(mc)


double click button(mc) stwingy
1/18/2004 11:19:41 PM
flash actionscript:
I need a way to double click a movieclip as need to be able to drag & drop it. This is a section of the code i am using
outbar1.numero = 1;
outbar2.numero = 2;
outbar3.numero = 3;
outbar4.numero = 4;
outbar5.numero = 5;
outbar6.numero = 6;
bigC = false;
function countup() {
if (counter<=50) {
counter += 1;
bigC = true;
} else if (counter>50) {
clearInterval(myInterval);
counter = 0;
bigC = false;
}
}
outbar1.onPress = outbar2.onPress=outbar3.onPress=outbar4.onPress=outbar5.onPress=outbar6.onPress=mover;
function mover() {
this.swapDepths(200);
clearInterval(myInterval);
myInterval = setInterval(countup, 10);
if (bigC) {
trace(this.numero);
scatter()
for (i=1; i<7; i++) {
_root["outbar"+i].slideTo(_root["outbar"+i].X, _root["outbar"+i].Y, _root["outbar"+i].speed);
}
}


this actually works and traces [outbar+i].numero on a double click but for some reason i have been unable to use this.( if you are thinking the syntax is incorrect, the function goes on another 100 lines or so.)
Please help.


Certified but not by Macromedia!
Re: double click button(mc) Pea
1/19/2004 2:39:00 AM
Hi,

Not sure about the code, you have, but here is some code you can try for double click:

1) Place a big invisible button in the clip. This is the area you can double-click on.
2) In the clip itself, place this code:

// Set defaults
clickedOnce = false;
clickedOnceCount = 0;

// This function runs once every frame.
function doubleClickCount(){
// If we have clicked once, increase counter
if (clickedOnce){
clickedOnceCount++;
// If the count is too high, reset click (wait too
// long between clicks on double click)
if (clickedOnceCount>10){
// Stop double click
clickedOnce = false;
}
}

// Set function to run every frame
this.onEnterFrame = doubleClickCount();

3) In the actions of the button itself, place this code:

// When the button is released
on (release){
// If the button hasn't been clicked at all, start double click code
if (!clickedOnce){
// Start counting
clickedOnce = true;
clickedOnceCount=0;
}else{
// Otherwise this is the second click of a double click
// Do whatever you need to do on double clcik here!

// e.g. Start dragging the clip:
this.startDrag(false);

}
}

Thats it!

Points to note - this code runs much better at higher framerates (upwards of 20fps) because this allows it capture clicks very close together.
Also, play around with the number in bold to change the time allowed between double clicks (for example, at 20fps, clickedOnceCount>10 allows half a second between clicks).

Hope it helps,
Pea

Re: double click button(mc) stwingy
1/19/2004 6:25:14 PM
After looking through your code, I found it is very similar to what i was already trying to do.(i`m using setInterval + no buttons). I had missed an else statement which i doubt i would ever have spotted without reading through your post.
Thankyou

Certified but not by Macromedia!
Re: double click button(mc) Paul J. Martinez
1/20/2004 7:07:28 AM
This might be useful as well.
http://proto.layer51.com/d.aspx?f=385


Take care,
Paul
--
http://fatlogic.com/
AddThis Social Bookmark Button