How to Change Symbol Position Horizontally and Vertically with Actionscript

Explorer ,
Oct 28, 2020

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? 

Views

49

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Oct 29, 2020
ClayUUID Adobe Community Professional , Oct 29, 2020
I'd think using the tween library would be vastly preferable to hand-coding a weak imitation of it.

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Oct 29, 2020

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);

}

}

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Oct 29, 2020

Copy link to clipboard

Copied

I'd think using the tween library would be vastly preferable to hand-coding a weak imitation of it.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Ece5F99 AUTHOR LATEST
Explorer ,
Oct 30, 2020

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Ece5F99 AUTHOR
Explorer ,
Oct 30, 2020

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);

}
}

 

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more