Professional Web Applications Themes

double click button(mc) - Macromedia 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=ou tbar5.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, ...

  1. #1

    Default double click button(mc)

    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=ou tbar5.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!
    myurl
    stwingy webforumsuser@macromedia.com Guest

  2. #2

    Default Re: double click button(mc)

    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


    Pea webforumsuser@macromedia.com Guest

  3. #3

    Default Re: double click button(mc)

    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!
    myurl
    stwingy webforumsuser@macromedia.com Guest

  4. #4

    Default Re: double click button(mc)

    This might be useful as well.
    [url]http://proto.layer51.com/d.aspx?f=385[/url]


    Take care,
    Paul
    --
    [url]http://fatlogic.com/[/url]
    [email]paul_NOSPAMfatlogic.com[/email]
    Paul J. Martinez Guest

Similar Threads

  1. double click causes click-event anddoubleClick-event
    By jpsouthern in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: April 14th, 09:27 PM
  2. WWW::Mechanize click($button) not finding right button to click
    By Bart Swordfish in forum PERL Modules
    Replies: 5
    Last Post: June 18th, 07:40 AM
  3. Replies: 2
    Last Post: May 28th, 06:23 AM
  4. Click / Double Click
    By joctobercanuck webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 22nd, 03:21 PM
  5. Single click vs double click in mouseDown and mouseUp
    By Alain Birtz in forum Mac Programming
    Replies: 3
    Last Post: September 3rd, 03:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139