Can't create multiple movieclips with an for loop

Hi,
i’m having a problem with a for loop. The problem is that it doesn’t create multiple movieclips with an unique instance, i think it copies over itself…
I hope someone knows how to solve this!!

thnx,
excidium

for( var i = 1, x = -20; i < 4; i++){

	if(this['plaatje' +i] != undefined){
	_root.again.createEmptyMovieClip("image", i);
	this._root.again.image += _root.again["image" +i];
	
	this.plaatje = this["plaatje"+i];
	trace(this['plaatje'+ i]);
	
	plaatjeText.text += this['plaatje'+i] + newline;
	_root.again.image.loadMovie(this.plaatje +".jpg", i);
	_root.again.image._x += 50;
	trace(_root.again.image3._x);
	
	
}}

Hoi excidium,

from what I see you forgot to put ‘+i’ in your createEmptyMovieclip line:

[AS]
_root.createEmptyMovieClip(“image”+i, i);
[/AS]

en welkom op het forum :slight_smile:

Ja dank je wel!

But… it doesn’t work, I tried that already. When I insert
’ _root.createEmptyMovieClip(“image”+i, i);’ it doesn’t show any image anymore. Then I thought, because I use the +i in the createEmptyMovie, maybe I must delete the ’ this._root.again.image += _root.again[“image” +i];’, but that doesn’t work either.
I keep having problems with the loadmovie() when loading a php variable (it’s an url to an picture). I was really happy when it worked with createEmptyMovieClip()…but now I’m still having problems with the ‘for’ loop for creating multiple movieClips with each having another picture.

Does someone has another solution?

thnx,
Excidium

I found out it makes the movieclips, cause when I check them seperatly like:

_root.again.image2.loadMovie(x2 +".jpg", i);
-> that works.

but not when i’m trying to show them with this code:

_root.again[image +i].loadMovie(x2 + “.jpg”, i);
y = 150;
_root.again[“image” + i]._y += -350 + y;
-> it shows only one image…

I have no idear how to solve this… Think I tried everything! :frowning:
plz help!

the right code:

for( var i = 0, x = -20; i <7; i++){

	if(this['plaatje' +i] != undefined){
	
	_root.again.createEmptyMovieClip("image"+i, i);
	
	trace(i)
	this.plaatje = this["plaatje"+i];
	trace(this['plaatje'+ i]);
	
	plaatjeText.text += this['plaatje'+i] + newline;
	x = 50;
	y = 150;
	
	_root.again["image"+i].loadMovie(this["plaatje" + i] +".jpg", i);
	
	_root.again["image" +i]._xscale = 50;
	_root.again["image" +i]._yscale = 50;
	_root.again["image" +i]._x += 100*i;
	_root.again["image" +i]._y += 100*i;

	
}}

thnx for replying,
excidium