Wouter
Wouter

Reputation: 1

Can i display multiple copies of a movieclip inside a array at once

Is there a way to make the code below work properly? When I use this code it only shows one movieclip:

var tempHead:head001 = new head001();
var mcArr:Array = new Array( tempHead );

var firstHead:MovieClip = mcArr[0];
firstHead.y = 30;
addChild(firstHead);

var secondHead:MovieClip = mcArr[0];
secondHead.y = 180;
addChild(secondHead);

`

Upvotes: 0

Views: 57

Answers (1)

Benny
Benny

Reputation: 2228

You were just assigning a reference to the MovieClip. That'y, its not working.

First take instance of head001 class using new operator as much you want and store it to an array, then you can access very easily.

var tempHead: head001;
var mcArr: Array = new Array();

for (var i: uint = 0; i < 2; i++) {
    tempHead = new head001();
    addChild(tempHead);
    mcArr.push(tempHead);
    mcArr[i].y = mcArr[i].height * i;
} 

Upvotes: 1

Related Questions