Jim
Jim

Reputation: 4172

How to set up Movieclip names to be refrenced by array

Ok I have a bunch of movieclips named p1, p2, p3, ..., pn all with actionscript identifiers the same as their names.

I would like to then say for an array looping through all of them, take "P" + i.y and change it.

So I would like to do this:

if (e.offsetY == 1) {
    "thisp" + currentPage.y ++;
}   

even making it a variable does not work

var movieclipName = "thisp" + .toString(currentPage)
novieclipName.y ++;

??

Upvotes: 0

Views: 64

Answers (2)

bitmapdata.com
bitmapdata.com

Reputation: 9600

Try with the following:

var currentPage:int = 0;
var movieclipName:MovieClip = this["p"+currentPage];
movieclipName.y ++;

Upvotes: 1

Vesper
Vesper

Reputation: 18747

This should help: getChildByName().

You have them all named "P" plus a number. Okay, call like this:

var thisp:DisplayObject=this.getChildByName('p'+currentPage);
thisp.y++;

Upvotes: 0

Related Questions