Skip to main content
Participating Frequently
November 14, 2008
Question

duplicate mc problem

  • November 14, 2008
  • 1 reply
  • 248 views
Hello

I am creating a flash file that duplicates a mc (jclip_mc) every few seconds or so on random places on the screen. This works.
I would also like to scale the mc depending on where on the screen it appears. If it appears on the upper half, it should scale 50%. On the lower half, no scale. This I can't make to work. The code is below.


mycount = 0;
function createjclip_mc() {
if (mycount<50) {
_root.jclip_mc.duplicateMovieClip("jclip_mc"+mycount,_root.getNextHighestDepth());
randomX = 500*Math.random() + 100;
randomY = 300*Math.random() + 100;
eval("jclip_mc"+mycount)._x = randomX;
eval("jclip_mc"+mycount)._y = randomY;
mycount++;

newmcname = ("jclip_mc"+mycount);
if (randomY < 250) {
_root.newmcname._yscale=50;
_root.newmcname._xscale=50;

} else {
_root.newmcname._yscale=100;
_root.newmcname._xscale=100;
}
} else {
clearInterval(ID);
for(var i = 0;i<50;i++){
removeMovieClip(eval("jclip_mc"+i));
}
}
}
ID = setInterval(createjclip_mc,4000);


I figured if I do this; newmcname = ("jclip_mc"+mycount);
to refer to the new mc name in the conditional if/else, it would work, but it doesn't.

Any help would be greatly appreciated.
This topic has been closed for replies.

1 reply

Ned Murphy
Legend
November 14, 2008
I haven't dug deeply into the code to be sure it'll work otherwise, but from what I do see, you are trying to treat a String as an object. Try this instead

_root[newmcname]._yscale=50;
etc

The stuff in the brackets is evaluated as an instance name
garydgAuthor
Participating Frequently
November 14, 2008
Thanks! I will try it.