Changing a movie clip's local variables

Hi all,

I’m working on a particle system, where each single particle is represented by a movie clip and has it’s own behaviors, defined in the movie clip’s code in a separate layer from the image. The particle creates local variables, such as it’s gravity and color, in the first frame and then uses them to guide it’s actions throughout it’s lifetime (it fizzles out and dies, eventually).

Frame 1 of particle_mc:


var gravity:Number = 0;
var color:Number = 2;
...etc...

Frame 2 of particle_mc:


switch (gravity) {
   case 0:
      this.x +=2;
      this.y += 2;
      break;
   case 1:
...etc...
}
...etc...

Frame 3 of particle_mc:


gotoAndPlay(_currentFrame - 1);

I would like to be able to place several of these particles on the stage in the root timeline, and set/change their gravities and colors from the root timeline’s actions layer. So that, if my particles are called part1, part2, etc, I could then say, from root:


part1.gravity = 2;
part2.gravity = 3;

or some such thing. However, the approach above doesn’t work. I’ve tried making a setGravity() function in the particle MC, and calling that from root as well, but that doesn’t work either. The only way that I’ve found to interact with the variables is if I go into the particle MC, and say “[FONT=Courier New]var gravity:Number = _root.grav1;[/FONT]” and on _root say “[FONT=Courier New]var grav1:Number = 2;[/FONT]”. But this won’t work for what I want to do because I want to have several particles falling in different directions at the same time. I would greatly appreciate any suggestions anyone has for me–I’ve tried searching for help on this topic, but I haven’t found any examples of people trying to actually change an MC’s local variables.

Thanks in advance,
AmandaC