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.
Well I figgured out my own question, But no one helped... o well
Just incase this gets looked up, you can do so by refering to the MC that veriable is set in like so:
if the veriable was
"DotCount" and it was in a MC called "Dots"
then, from a differant MC you can use
_root.Dots.DotCount
get it good.
-------------------------------------
The problem now, with my game, is that after you let go of the mouse, then click again, the first bullet aims at the position you let go at, not the new position, How can i fix this...
Updated fla below. Maybe someone can help this time