A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [MX] Sharing veriables between mc's

Hybrid View

  1. #1
    Guy With A Question
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    35

    [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.
    Last edited by Question?; 07-09-2006 at 02:47 AM.
    OK! OK!... Potatoes it is

  2. #2
    Guy With A Question
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    35
    here is the swf, you will see what i mean if you play it.
    Attached Files Attached Files
    OK! OK!... Potatoes it is

  3. #3
    Guy With A Question
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    35
    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
    Attached Files Attached Files
    OK! OK!... Potatoes it is

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center