Free ActionScript

Flash AS2 & AS3 Tutorials, Game Code, Effects, Source Files & Sample Downloads

Scroller – Dynamic Scrollbar v2

A newer, better version of my scrollbar class. This one does not have any classes attached to movieclips. Instead you pass it a content clip, mask clip, track clip and slider clip like so:

_scrollbar = new Scrollbar();
_scrollbar.init(content, contentMask, track, slider);

This version also supports mouse wheel scrolling.

Download Fla Sample

Download Fla Sample

Projectile Weapon

AS3 update to my AS2 projectile weapon script. Features click-to-shoot (machine gun), collision detection, bullet gravity.

Available Settings

  • Bullet Speed – how fast the bullet travels
  • Max Distance – how far the bullet can go before dying
  • Reload Speed – how long it takes to reload the weapon
  • Barrel Length – how far from player does the bullet starts
  • Bullet Spread – how accurate does the bullet fly towards target
  • Gravity – gravity on/off

Preview

Download Fla Sample

Download Fla Sample

Update
Advanced multi-barrel OOP version of this weapon script is now available here:
http://www.freeactionscript.com/2011/08/advanced-weapon-system/

Laser Weapon (with wall collision detection)

This is an AS3 update to my old AS2 laser script with a few improvements:

  • You can now easily check if the laser is hitting multiple walls by adding movieclips to an array
  • I also added a delayed turret rotation – this way the turret doesn’t feel “glued” to the mouse
  • Optimized and cleaned up the code

You can set the following weapon settings:

  • turret rotation speed – how fast turret rotates towards mouse. default is 20
  • barrel length – how far from turret laser starts drawing. default is 15
  • laser range – default is 100
  • laser color – default is green #00FF00
  • laser width – default is 2
  • laser blur strength – default is 2

Preview

Download Fla Sample

Download Fla Sample

Enemy AI – Patrol

New enemy AI patrol script. Movieclip follows a predefined set of point markers stored in an array.

Features

  • Accelerate/Decelerate
  • Smooth movement & rotation
  • Bounce off walls on collision
  • Go to next point once destination is reached
  • Easily add/remove destinations

Preview

Download Fla Sample

Download Fla Sample