A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Constantly Checking On Mouse Down

  1. #1
    i am making a shooting game that has a machine gun as a power up. i want it to constantly fire it while u hold down the mouse button. right now i have a huge invisible button that has the on "Press" action. using this, it only fires once while u hold down the button. Is there a way around this? i tried making an mc that checks "on mouse down" & it did the same thing. i was thinking of maybe setting a variable or something. if anyone knows how to do this, please let me know.


  2. #2
    Senior Member
    Join Date
    May 2001
    ok what you need is a trigger MC. what this is is a small invisable(no objects in it) MC that loops thru a couple of frames to continue an action. I used it for continuously scoll.

    to make one:
    make a blank MC
    in frame 1 put a stop command
    in frame 2 have it do the action you want (ie fire weapons, duplicate MC, whatever)
    in frame 3 have a gotoandplay(2) script
    put the MC in the root, and name it "firetrigger"
    now in your button, make a script: _root.firetrigger.gotoAndPlay(2) on press
    and on release, _root.firetrigger.gotoAndStop(1)

    you're done

  3. #3

    It works! :)

    Wow, thanks Anti-Matter0!

    All i had to do was add a couple more frames to the firetrigger mc so that it doesn't fire the gun too fast.

    Thanks again!

  4. #4
    Senior Member
    Join Date
    May 2001
    yep. i love that code. untill i found functions, i use "trigger" mcs for everything.

    just as a side noteway off topic) theres a type of MC called a "droplet" that is almost the same as a trigger, the difference is that it is used to modify the parent that it's in. so if i wanted to randomly scale the x axis i would make a droplet that did so to the _parent of it and all i would have to do is place the droplet inside the MC i wanted it to modify.

    just FYI

Posting Permissions

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

Click Here to Expand Forum to Full Width

HTML5 Development Center