Skip to main content
oliversen
Inspiring
June 18, 2018
Answered

next frame movieclips

  • June 18, 2018
  • 1 reply
  • 857 views

Hey

I am creating several buttons using a for loop - about 100 buttons.

for (var i: int = 0, total: int = xmlLengde; i < total; i++) {

bgmList.push(myXML..Song.songURL)

button1 = new Favorite();

button1.name = "favorite" + i;

button1.mouseChildren = false;

button1.y = button.y + (button.height - button1.height) / 2;

button1.x = button.x + button.width - 10 + button1.width / 2;

container1.addChild(button1);

}

I have an array like this:// this is traced - FavoritterID:       5,6,1,2,13,88,73.

All the buttons are movieclips that has 2 frames.

What I want to do now is make favorite5, favorite6, favorite1 and so forth go to next frame.

I have tried this and a few other things. Doesnt seem to work.

for(var ii: int =0, ii<FavoritterID.length; ii++){

button1.nextFrame();

favorite+i.nextFrame();

}

thanks

This topic has been closed for replies.
Correct answer kglad

I thought I might had to use punctation when refering to a movieclip inside a container. As is common when I for instance create a eventlistener

container1.favorite22.addEventListener(...


oops, you don't have any objects with reference favorite0, favorite1 etc.  those are all name properties.  ie, use

for(var p: int =0; p<FavoritterID.length; p++){

MovieClip(container1.getChildByName('favorite'+p)).nextFrame();

}

1 reply

kglad
Community Expert
Community Expert
June 18, 2018

use array notation to coerce strings to objects:

user

for (var i: int = 0, total: int = xmlLengde; i < total; i++) {

bgmList.push(myXML..Song.songURL)

button1 = new Favorite();

button1.name = "favorite" + i;

button1.mouseChildren = false;

button1.y = button.y + (button.height - button1.height) / 2;

button1.x = button.x + button.width - 10 + button1.width / 2;

container1.addChild(button1);

}

for(var ii: int =0; ii<FavoritterID.length; ii++){

this['favorite'+ii].nextFrame();

}

Legend
June 18, 2018

Fixing the use of "ii" as the iterator variable would also help. And the comma in the for loop instead of a semicolon.