Duplicate mc Script problems

Ok… I tried to put the following script into my mc…

[AS]onClipEvent (load) {
amount = 10;
while (amount>0) {
duplicateMovieClip(_root.flower, “mc”+i, i);
setProperty(“mc”+i, _x, random(275));
setProperty(“mc”+i, _y, random(275));
setProperty(“mc”+i, _alpha, random(275));
setProperty(“mc”+i, _xscale, random(50));
setProperty(“mc”+i, _yscale, random(50));
i++;
amount–;
}
}
[/AS]

When I try to run it gives me this message:

  A script in this movie is causing flash player to run slowly. If it continues to run, your computer may become unresponsive.Do you want to abort the script?

… Is it something in my script how could I fix this?? I’ve attached the file.

is it ON flower? if so, when duplicating it, that script will remain and be run on all duplicates thereby creating an infinite loop.

on a side note, i is never changed in that script which mean the duplicate will only be made once… well more than once but since i stays the same each new duplicate will replace the prior

Ok it’s on that mc…but you totally lost me…I still don’t understand what I’m supposed to change…

You can’t place it on the image itself, because when it’s duplicated, it will have the same code on it I think and therefore every duplicated movieclip will dyuplicate itself again 10 times. And each of those will duplicate themselves too. And so on. So I suggest you code in the timeline.

Well I put my current code in the main timeline and that doesn’t do anything…could you give me and example of what your talking about?

This is the current script I have in the timeline…(I changed the instance names…)

[AS]
amount = 10;
while (amount>0) {
duplicateMovieClip(_root.target_mc, “target_mc”+i, i);
setProperty(“mc”+i, _x, random(275));
setProperty(“mc”+i, _y, random(275));
setProperty(“mc”+i, _alpha, random(275));
setProperty(“mc”+i, _xscale, random(50));
setProperty(“mc”+i, _yscale, random(50));
i++;
amount–;
}
[/AS]

On the timeline in which flower is in …


amount = 10;
for(var i=0;i<=amount;i++){
                mc = flower.duplicateMovieClip("mc"+i, i);
                mc._x = Math.floor(Math.random()*(275+1))
                mc._y = Math.floor(Math.random()*(275+1))
                mc._alpha = Math.floor(Math.random()*(275+1))
                mc._xscale = Math.floor(Math.random()*(50+1))
                mc._yscale = Math.floor(Math.random()*(50+1))
// Good like this, sen ? ;-)
}

That should do it :slight_smile:

whoa…wierd…I stick that in…and well look at the attached screen shot…very wierd…I really don’t understand…

Everything looks warped…or something…I’m guess it has something to do with the MathRandom…

yeah. Well it IS random :wink:

Ok but what would I do just to have non-skewed targets of different sizes duplicating at different locations and depths?

hello??

amount = 10;
for (var i = 0; i<=amount; i++) {
	mc = flower.duplicateMovieClip("mc"+i, i);
	mc._x = Math.floor(Math.random()*(275+1));
	mc._y = Math.floor(Math.random()*(275+1));
	mc._alpha = Math.floor(Math.random()*(275+1));
	mc._xscale = mc._yscale=Math.floor(Math.random()*(50+1));
}

thanks claudio…that one seems to work the best so far… :slight_smile:

welcome :slight_smile: