I have alot of mc’s and I want them all to have the same code applied to them without having to copy/paste all the code in each one and also it would be easier for any changes latter. I have tried making the code a function and then calling it inside the mc’s but it did not work and I am fairly new at functions themselves so I am stuck.
This is the code below-
onClipEvent (load) {
targetx = this._x;
targety = this._y;
this._y = 0;
this._x = 0;
speed = 4;
size = random(100);
this._xscale = size+100;
this._yscale = size+100;
onEnterFrame = function () {
this._x += (targetx-this._x)/speed;
this._y += (targety-this._y)/speed;
this._alpha += (0-this._alpha)/7;
if (this._alpha<=0) {
this.removeMovieClip();
}
};
}
The code marks the mc position, then moves it to 0,0 then moves back to the original postion while degrading alpha. I set it up this way so I can arrange the mc in any shape and the mc’s will look like they explode into the shape when played. It is used for a fireworks effect.
Thanks