imports
public class Particle_Rain extends Entity
{
private var _emitter:Emitter;
[Embed(source = "../assets/graphics/particles/rain.png")]
private const RAIN:Class;
public function Particle_Rain()
{
_emitter = new Emitter(RAIN, 1, 80);
_emitter.setAlpha("rain", 0.8, 0);
_emitter.newType("rain", [0]);
_emitter.setMotion("rain", 180, 100, 3, 360, 360);
_emitter.setGravity("rain", 40)
graphic = _emitter;
layer = -99;
}
public function rainCreate(_x:Number, _y:Number, part:Boolean = false):void
{
var particles:int = 0;
if(part) particles = FP.choose(4, 5, 6);
else particles = FP.choose(2, 3);
for (var i:uint = 0; i < particles; i++)
{
_emitter.emit("rain", _x, _y - 8) ;
}
}
}
The error is
[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
It works if I don’t use setalpha.
I don’t understand why?
Also: Extra question, how can I enable normal alpha levels on the image? So I don’t have to tween it.