PDA

View Full Version : Flash 5 - Arrays


Ash
01-05-2001, 02:14 PM
OK I'm having fun with arrays. But one thing has me stumped.

I can create an array of movieclips no problem.

But is it possible to dynamically create an array of movieclips at runtime using duplicatemovieclip.

I thought it should be but every attempt I have made to date has been a dismal failure.

Thanks in advance.... nice site!

FlashGuru
01-07-2001, 01:23 AM
to create an array of movieclips when using the duplicateMovieClip command simply use:

movieclips=new Array()
for(i=1;i<=nummovieclips;++i){
duplicateMovieClip("originalmovieclip","newname"+i,i)
movieclips.push("newname"+i)
}

now to target any one of those movieclip simply use:

_root[movieclips[index]].do something

Hope that helps!

Ash
01-07-2001, 09:40 PM
Thanks FG. That helps.

I was using ' "newname" & i ' rahter than ' + i ' because I thought I'd seen it in an example a while back.

Does this not work or are they both the same?

Jesse
01-07-2001, 11:25 PM
The ampersand (&) is the Flash 4 concatenate symbol. Now, in Flash 5 we're supposed to use '+' or 'add'

Cheers

Jesse