Skip to main content
Participant
April 8, 2014
Answered

Converting AS2 to AS3 Please!

  • April 8, 2014
  • 1 reply
  • 588 views

Hi guys.

I having a major problem in trying to convert an old AS2 code into AS3.

It would be great if you guys could help in anyway you can.

onClipEvent (enterFrame)

{

    this;

    if (_x > 520)

    {

        setProperty(this, _x, -20);

    } // end if

    this;

    if (_x < -20)

    {

        setProperty(this, _x, 520);

    } // end if

    setProperty(this, _x, _x + Number(1.250000E+000));

}

This topic has been closed for replies.
Correct answer Ned Murphy

In the timeline of the object in question, try:

addEventListener(Event.ENTER_FRAME, moveX);

function moveX(evt:Event):void {

    if(x > 520){

         x = -20;

    }

    if(x < -20){

         x = 520;

    }

    x += 1.25;

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 8, 2014

In the timeline of the object in question, try:

addEventListener(Event.ENTER_FRAME, moveX);

function moveX(evt:Event):void {

    if(x > 520){

         x = -20;

    }

    if(x < -20){

         x = 520;

    }

    x += 1.25;

}

leeno77Author
Participant
April 8, 2014

thank you very much

Ned Murphy
Legend
April 8, 2014

You're welcome