Skip to main content
Inspiring
October 28, 2020
Answered

How to Change Symbol Position Horizontally and Vertically with Actionscript

  • October 28, 2020
  • 1 reply
  • 508 views

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? 

    This topic has been closed for replies.
    Correct answer ClayUUID

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

    1 reply

    kglad
    Community Expert
    Community Expert
    October 29, 2020

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

    }

    }

    ClayUUIDCorrect answer
    Legend
    October 29, 2020

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

    Ece5F99Author
    Inspiring
    October 30, 2020

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