Copy link to clipboard
Copied
Hi,
I want to change the position of the symbol i created with Actionscript to a certain length, first from top to bottom, then from right to left. Can you help me?
1 Correct answer
I'd think using the tween library would be vastly preferable to hand-coding a weak imitation of it.
Copy link to clipboard
Copied
you would change the symbol's x and y properties using the symbol's instance name. for example, if mc1 is at 0,0 and you want to change that to 100,200:
mc1.x = 100;
mc1.y = 200;
if you want to animate the position change, you would use a loop (eg, enterframe) to repeatedly update the x and y properties:
this.addEventListener(Event.ENTERFRAME, loopF);
function loopF(e:Event):void{
if(mc1.x<100){
mc1.x += 2; // different values from 2 would change the speed.
}
if(mc1.y<200){
mc1.y += 2;
}
// done animate this move, terminate loop
if(mc1.x>=100 && mc1.y>=200){
this.removeEventListener(Event.ENTERFRAME, loopF);
}
}
Copy link to clipboard
Copied
I'd think using the tween library would be vastly preferable to hand-coding a weak imitation of it.
Copy link to clipboard
Copied
I need to examine a little more what I can do with the library. The solution was practical for me. Thank you.
Copy link to clipboard
Copied
First of all, thank you for your information.
I tried using it and encountered an error like this:
Scene 1, Layer 'Layer_1', Frame 1, Row 7, Column 10 1021: Replication function definition.
I think, I couldn't fully use it.
var mc1:Circle = new Circle(); // where you have a symbol in the library with linkage id = MC
addChild(mc1);
this.addEventListener(Event.ENTER_FRAME, loopF);
function loopF(e:Event):void{
if(mc1.x<100){
mc1.x += 2; // different values from 2 would change the speed.
}
if(mc1.y<200){
mc1.y += 2;
}
// done animate this move, terminate loop
if(mc1.x>=100 && mc1.y>=200){
this.removeEventListener(Event.ENTER_FRAME, loopF);
}
}

