Particle effect using movieclips from library

Hi all,

so I am requesting a little help to connect a few pieces of code I have; the end result being a particle effect that propels 9 different movieclips (pulled from the library) off ‘into space’.

Here is the code to call a single movieclp, which I was able to create myself :


var i:Number=0;
function createMusic() {
    origin.attachMovie('music', "music"+i, i);
    i++;
}
myinterval = setInterval(createMusic, 500);

Here is code that I found on another post, that seems to call more than one movieclip onto the stage : please note that it is in its original form, check below for my attempt.


createThingSpeed = 2000;
var i = 0;
var myinterval;
cliparray = [ ];

newThing = new Array('blue', 'green', 'red', 'tint', 'yellow', 'black', 'purple');
newThrow = new Array({mc:"drop1", x:100, y:100}, {mc:"drop2", x:100, y:100}, {mc:"drop3", x:100, y:100}, {mc:"drop4", x:100, y:100});
function shuffle() {
    return Math.floor(Math.random()*3)-1;
}
newThrow.sort(shuffle);
newThing.sort(shuffle);
function makemovies() {
    var clip = attachMovie(newThrow*.mc, newThrow*.mc, i);
    trace(newThrow*.mc);
    clip._x = newThrow*.x;
    clip._y = newThrow*.y;
    clip.attachMovie(newThing*, newThing*, 1);
    i<newThrow.length-1 ? i++ : clearInterval(myinterval);
}
myinterval = setInterval(makemovies, 2000);

Here is my attempt to call movies from the library :


newMusic = new Array('blue', 'green', 'red', 'tint', 'yellow', 'black', 'purple');
function shuffle() {
    return Math.floor(Math.random()*3)-1;
}
newThing.sort(shuffle);
function makemovies() {
        origin.attachMovie(newMusic, newMusic, 1);
        trace("hit");
}
//set interval to make it play

And here is the movement code, which I was able to make work on a mc already on the stage. This code is from another forum post.


//duplicate mc, and then...
onLoad = function() {
    this.origin.music._x = 100;
    this.origin.music._y = 100;
    speed = .03;
    gravity = .03;
    spread = -1+Math.random()*(2);
    trace("hit");
};
onEnterFrame = function() {
    this.origin.music._x += speed;
    this.origin.music._y += spread;
    speed += gravity;
    if (_y>400) {
        this.removeMovieClip();
    }
};

I would like to use the 1st code block and the 3rd and 4th code block together, to call all nine of the ‘color’ mcs to the stage and have them fly off. I seem to have trouble with target paths. And my main problem is some sort of tracker that can track all the ‘color’ mcs on stage, and apply the physics to them. I wanted to provide you with all of the code, and I know it is quite a mess - obviously many pieces from seperate code quotes don’t belong together, and can be replaced. The final design could be distilled into three general ideas:

//load 1 through 9 mcs, randomly
//track mcs on the stage
//apply mc names to physics code

I just wanted to provide my process so that anyone can see that I am thinking about these things.

Thanks for the help!

Nick