0

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 ++;

??

Jim
  • 3,821
  • 1
  • 28
  • 60

2 Answers2

1

Try with the following:

var currentPage:int = 0;
var movieclipName:MovieClip = this["p"+currentPage];
movieclipName.y ++;
joce
  • 9,624
  • 19
  • 56
  • 74
bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
0

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++;
Vesper
  • 18,599
  • 6
  • 39
  • 61
  • but what if the movieclip p1 is not a child of whatever flash thinks is "this"? – Jim Mar 02 '13 at 21:14
  • Well, it's possible, if so, use alternate solution (right above). Also, use a "tick" button to accept an answer if it worked for you. – Vesper Mar 03 '13 at 05:41
  • Even if you have 1 reputation, you can tick an answer. An upvote is an up arrow above the big number, which indeed requires 10 rep. A tick is located below the downvote arrow. – Vesper Mar 07 '13 at 03:31
  • @Jim It was so long ago I've forgot. Thanks. – Vesper Mar 12 '13 at 16:08