Skip to main content
Known Participant
September 18, 2009
Question

Translate AS2 code to AS3

  • September 18, 2009
  • 1 reply
  • 635 views

sliceArray=["slice1","slice2","slice3","slice4","slice5","slice6","slice7",
"slice8","slice9","slice10"];

function rotateMC(num:Number)
    {
    for (i=0;i<= sliceArray.length;i++)
        {
            var myName=eval(sliceArray);
            myName._rotation+=num;
        }
    }

btn1.onPress=function(){
this.onEnterFrame=function(){
    rotateMC(10);
}
}

btn1.onRelease=function(){
delete this.onEnterFrame;
}

btn2.onPress=function(){
this.onEnterFrame=function(){
    rotateMC(-10);
}
}

btn2.onRelease=function(){
delete this.onEnterFrame;
}

This topic has been closed for replies.

1 reply

Inspiring
September 18, 2009

the generic answer to your generic question would be to learn AS3. Do you have a specific question?

What have you tried on your own? Are you stuck on a specific part?

I don't think you can use eval anymore (and it has been a bad idea since Flash 6 anyways) so for that you can use the array notation:

someParentObject["childname"+variable]

And all the various different ways of handling events have been replaced with:

someObject.addEventListener("theEvent",handlerFunction)

function handlerFunction(e:Event):void{

// code here

}

Known Participant
September 18, 2009

I just need that translated to AS3. Itried myself but I can't get it to work. I'm well aware that eval doen't exist in AS3 and thanks for that groundbreaking news about how to listen to events and write functions in AS3.