[MX] Sharing veriables between mc's
There may be a better way to go about this, but for the moment i have this code in one movieClip
Code:
onClipEvent (load) {
var n:Number = 1;
}
onClipEvent (mouseDown) {
shoot = 1;
}
onClipEvent (mouseUp) {
shoot = 0;
}
onClipEvent (enterFrame) {
if (shoot == 1) {
//----Find all angles and velocities at when mouse down----
var shotVelocity:Number = 10;
var ya:Number = shotVelocity*Math.cos(trtAng);
var xa:Number = shotVelocity*Math.sin(trtAng);
trtAng = Math.atan2((_root.ship._x)-_root._xmouse, (_root.ship._y)-_root._ymouse);
//----duplicate lazzer and set positions----
duplicateMovieClip(_root.laz, "laz"+n, n);
_root["laz"+n]._x = _root.ship._x;
_root["laz"+n]._y = _root.ship._y;
_root["laz"+n]._rotation = trtAng/-(Math.PI/180);
n++;
}
}
and this code on the Lazzer or "laz" movieclip:
Code:
onClipEvent (enterFrame) {
//----Move Current bullet----
this._x -= xa;
this._y -= ya;
if (this._x>500 or this._x<0 or this._y>500 or this._y<0) {
removeMovieClip("");
}
}
the xa and ya varibles are defined in the first code, i could just define thim again in the second code but, could i just some how share the veriables between the mc's?
ps if you don't understand the consepts tell me and ill attach the swf file
thanks if you can help
EDIT:
My real problem is that i only want to edit the trig velocities for the newest bullet, instead of changing all of them and affecting their current cource.