particle array null refrence

I’m just messing around trying to add some external effects to my particles(particle attraction in this case). but it seems my particle array isn’t being filled, or something is going wrong when i try to fill it with my particleSystem’s getParticles() function.
i must be creating the array wrong or trying to fill it incorrectly. can anyone see my problem?

#pragma strict
var target : Transform;
var power = 5.0;
var PA: ParticleSystem.Particle[];
var heading:Vector3;
function Start () 
{

}

function Update () 
{
	particleSystem.GetParticles(PA);
 	for(var p in PA)
 	{
 		heading = target.position - p.position;
 		p.velocity += heading.normalized * power;
 	}
 	particleSystem.SetParticles(PA, PA.Length);
}

error is at the ‘for’ line:

NullReferenceException: Object reference not set to an instance of an object

i also tried this for loop, but got the same error:

 	for(var i = 0; i < PA.Length; i++)
 	{
 		heading = target.position - PA*.position;*

PA_.velocity += heading.normalized * power;_
* }*

I think, you dont’t using prewarm options for your particle. Than, in 1st frame count of your particle, probably, is 0. Than for 1st frame array PA is null. Than:

 #pragma strict
 var target : Transform;
 var power = 5.0;
 //Initialization your array
 var PA: ParticleSystem.Particle[] = new ParticleSystem.Particle[1000];
 var heading:Vector3;
 function Start () {

 }

 function Update ()  {
  var myLen: int = particleSystem.GetParticles(PA);
  if (PA != null) {
   for(var i: int = 0; i < myLen; i++) {
    heading = target.position - PA*.position;*

PA_.velocity += heading.normalized * power;_
}
particleSystem.SetParticles(PA, myLen);
}
}
Of course, you use GetParticle in “if”: return number of particle. I hope that it will help you.