• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Change Symbol Position Horizontally and Vertically with Actionscript

Explorer ,
Oct 28, 2020 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

228

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Oct 29, 2020 Oct 29, 2020

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

Votes

Translate

Translate
Community Expert ,
Oct 29, 2020 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);

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2020 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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

I need to examine a little more what I can do with the library. The solution was practical for me. Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 30, 2020 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);

}
}

 

 

Votes

Translate

Translate

Report

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