AS2 carousel gallery to AS3

294 Views Asked by At

I'm making carousel gallery for my class, however we got a code written in AS2 and have to transform it into AS3. I have a problem with two fragments:

// create the objects for the circular motion 
for (var i:Number = 0; i < numberOfObjects; i++) 
{
    this.createEmptyMovieClip('object'+i, i);
    this['object'+i].loadMovie('p'+(i+1)+'.jpg');
}

Where I'm adding movie clips as objects, and then I want to use them as:

// create the motion along the circular path
this.addEventListener(Event.ENTER_FRAME, function()
{   
    // loop over all the objects
    for (var i:Number = 0; i < numberOfObjects; i++) 
    {   
        thisObj = this['object'+i]; 
        placeObj(thisObj,i);
        displayObj(thisObj);
    }
})

Of course I get an exception:

Scene 1, Layer 'actions', Frame 1, Line 85  1120: Access of undefined property thisObj.

I know that createEmptyMovieClip as well as loadMovie don't work in AS3, and I probably should make MovieClip as new MovieClip, however I still have troubles how to make this work. I'll be truly grateful for any advices.

1

There are 1 best solutions below

0
On

You need to apply var keyword before you introduce a new variable.

Correct your as3 code this:

var thisObj:Sprite = this['object'+i];