hello,
How do you do?
Iam new to actionscript 3 also new to english launguage.
I have made 3 as.file , 1- Main, 2 -A and 3-B.
File A and B contain both a moving sprite(circle) for the stage.
What i need is the coordinates X and Y of the “MOVING SPRITE” on stage from as.file 3-B to pass the variable into as.file 2-A.
I could merge both as.file into Main.as file, but thats not my goal !!!
I dont know if its possible, i search google and tried many option without succes.
hopefully you guy’s can help me .
Below i show the code.
thnx for your time and reading.
package
{
import flash.display.*;
import flash.events.*;
public class a extends Sprite
{
public var cirleA:Sprite;
public var speed:Number = 7;
public var coordinatesX:Number;
public var coordinatesY:Number;
public function a()
{
cirleA = new Sprite ();
cirleA.graphics.beginFill(0x000000);
cirleA.graphics.drawCircle(0,0,10);
addEventListener(Event.ENTER_FRAME, movecirleA);
}
function movecirleA(event:Event)
{
cirleA.x += speed / 4;
cirleA.y += speed / 7;
/*coordinatesX = cirleB.x ; <=========== this is what i need,
coordinatesY = cirleB.y ;*/// <========= dunno how to do it !!!
addChild(cirleA);
}
}
}
package
{
import flash.display.*;
import flash.events.*;
public class b extends Sprite
{
public var cirleB:Sprite;
public var speed:Number = 7;
public function b()
{
cirleB = new Sprite ();
cirleB.graphics.beginFill(0xff0000);
cirleB.graphics.drawCircle(0,0,10);
addEventListener(Event.ENTER_FRAME, movecirleB);
}
function movecirleB(event:Event)
{
cirleB.x += speed / -4;
cirleB.y += speed / 7;
addChild(cirleB);
}
}
}
package
{
import a;
import b;
import flash.display.*;
public class Main extends Sprite
{
public var circleA:a;
public var circleB:b;
public function Main()
{
circleA = new a ();
circleB = new b ();
circleB.x = 450;
circleB.y = 0;
addChild(circleA);
addChild(circleB);
}
}
}