I am new on AS3, trying to learn it. Trying to create game, with main time line and many movieclips in it. I have a few variable in main timeline, and I want to change them each time by clicking each diferent movieclip. let say, I have stage coordinates cx and cy, and then I click on Any movieclip i want to change these vars to the cordinates the movieclip is. Here what i did:
Main timeline
import flash.events.MouseEvent;
import fl.motion.Color;
import fl.motion.MotionEvent;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.InterpolationMethod;
var cx:int; //stage coordinate x;
var cy:int; //stage coordinate y;
var tx:int; //table coordinate x;
var ty:int; //table coordinate y;
c1.addEventListener(MouseEvent.CLICK, tracing);
c2.addEventListener(MouseEvent.CLICK, tracing);
function tracing(e:MouseEvent):void {
e.currentTarget.gotoAndPlay(1);
trace(cx,cy,tx,ty);
}
c1 movieclip (symbol name mc1) code on first frame:
MovieClip(root).cx=0;
MovieClip(root).cy=0;
MovieClip(root).tx=0;
MovieClip(root).ty=0;
c2 movieclip (symbol name mc2) code on first frame:
MovieClip(root).cx=85;
MovieClip(root).cy=85;
MovieClip(root).tx=85;
MovieClip(root).ty=85;
the problam is I always get value of the first movieclip I clicked. I kinda found solution for that, but i dont think it should be like that, in each mc1 and mc2 I made second empty keyframe, and now its working, but I dont think it should be like this, what am I doing wrong, any way to do without creating more frames in movieclips?