This AS2 example shows you how to make projectile weapons for your flash games; a pistol, a shotgun, and a machine gun. Holding down the mouse button allows you to fire continuously.
Note: Latest version of this script is located here:
http://www.freeactionscript.com/2009/06/flash-game-projectile-weapons/

Just what i needed! I tried several things to make a spread shot. I just didnt think of using a loop inside the function. good call. A++
Glad you found it useful
any ideas on how to make the bullet fire from the tip of the gun instead of the middle. I tried changing the bullet position but no luck
Werty2334; i will fiddle around with the fla and see. Will post results here
Hey Werty2334, I thought I’d post some code (that I used in a previous project) in response to your comment. Replace the following code:
tempBullet._x = player_mc._x;tempBullet._y = player_mc._y;
With:
tempBullet._x = player_mc._x+15*Math.cos(player_mc._rotation*radians);tempBullet._y = player_mc._y+15*Math.sin(player_mc._rotation*radians);
You can replace the 15 with any distance you like (in pixels). Hope it helps! I’m looking forward to your solution as well, pradvan.
- Noah
Hi, good job man, great stuff.
I am trying to make a game, and I can seem to get a hitTest to work with the bullets hitting an object.
Let me know what to do. Thanks.
-Boggie
Im With Boggie ^
I am using this scrip with a few changes and custom work, but no matter what I try I can’t get the hit test to work, I have read the script over and over and tried differnt thing, looked at other .fla this dev has made and still can’t figure it out. Anyone have an idea to get hit test to work
When I try using the enemy follow script with this script, the enemies follow my character but the character does not shoot whenever I click, my character cannot rotate towards the mouse as well. Is there someway the script can be tweaked so that it does not interfere with this script?
Hi guys, I will release an update to this script sometime this week. It should address all your issues.
Thanks,
PR
Here is the latest version:
http://www.freeactionscript.com/2009/06/flash-game-projectile-weapons/