I lost the source code to my game where I did something similar for a flamethrower, but here is the class decompiled.
Fireball.as
package
{
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import net.flashpunk.tweens.misc.*;
public class fireball extends Entity
{
private const flame:Class;
public var fireGFX:Image;
private var angle:Number;
private var vx:Number;
private var vy:Number;
private var speed:Number;
private var duration:Number;
public function fireball(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number)
{
this.flame = fireball_flame;
this.fireGFX = new Image(this.flame);
super();
this.x = param1;
this.y = param2;
this.angle = param3;
this.speed = param4;
this.duration = param5;
this.vx = Math.sin(this.angle * FP.RAD);
this.vy = Math.cos(this.angle * FP.RAD);
this.fireGFX.alpha = 0.75;
graphic = this.fireGFX;
setHitbox(6, 6);
type = "fire";
layer = 1;
}
override public function added() : void
{
var _loc_1:VarTween = new VarTween(this.die);
_loc_1.tween(this.fireGFX, "alpha", 0, this.duration);
addTween(_loc_1, true);
}
override public function update() : void
{
if(Player.pause)
{
}
else
{
x = x + (this.vx * this.speed);
y = y + (this.vy * this.speed);
if(collide("enemy", x, y))
{
die();
}
}
}
private function die() : void
{
if(this.world)
{
world.recycle(this);
}
}
override public function updateTweens() : void
{
if(Player.pause)
{
return;
}
super.updateTweens();
}
}
}