# Pulling my hair out over nothing?

**URL:** https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255
**Category:** Uncategorized
**Created:** [July 29, 2004, 5:25pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255 "2004-07-29T17:25:48Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![rickface](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@rickface](https://forum.kirupa.com/u/rickface)
#### Post date: [July 29, 2004, 5:25pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/1 "2004-07-29T17:25:48Z")

</div>

I think i am having some issues concatenating and calling the instances in my for loop here…can anyone see anything wrong with the syntax or any other reason why this might not work? Anything that would make this thing not work? Ive been trying for hours, can figure it out ☹

for(i=2; i\<=10; i++){  
duplicateMovieClip(mask0\_mc,“mask”+i+"\_mc", 1)  
j=i-1  
trace([“mask”+j+"\_mc"].\_width)  
trace(“mask”+j+"\_mc")  
[“mask”+i+"\_mc"].\_width = ([“mask”+j+"\_mc"].\_width\*1.1)  
[“mask”+i+"\_mc"].\_x = ([“mask”+j+"\_mc"].\_x - [“mask”+i+"\_mc"].\_width);  
}

tracing the width gives me underfinded while tracing the mask+j+\_mc, gives me the instance names of the clips :?

please tell me that Im lame and this is an easy syntax thing :? 🙂

thx in advance for any help.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 29, 2004, 5:38pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/2 "2004-07-29T17:38:29Z")

</div>

Well I could be wrong but duplicate movie clips works with three parameters: target, new name, and depth. You’ve got:  
duplicateMovieClip(mask0\_mc,“mask”+i+"\_mc", 1)

Looks to me like you are duplicating all of your movie clips on to one depth, which means essentially that every duplication is replacing the previous one. Each movie clip has to occupy its own depth space. So change the 1 to i and see if that works.

This is just a first glance guess at what might be going on with your code.

:hr:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 29, 2004, 6:03pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/3 "2004-07-29T18:03:12Z")

</div>

ahh, there have been so many versions of this block of code its hard to keep track 🙂

I have tried that before and just changed it back. The mc’s appear to be duplicating when the for loop runs, it just seems that I cant call the properties of the newly formed clips. Could this be for some reason because they are being placed at diff depths?

the output withdow spits out:  
undefined  
mask1\_mc  
undefined  
mask2\_mc  
undefined  
mask3\_mc  
undefined  
mask4\_mc  
undefined  
mask5\_mc  
undefined  
mask6\_mc  
undefined  
mask7\_mc  
undefined  
mask8\_mc  
undefined  
mask9\_mc

“undefined” is whats happening when im trying to get the width property of the newly created movie clips. Any other ideas?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 1:04am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/4 "2004-07-30T01:04:56Z")

</div>

can anyone else shed any light on this? Ive gotten the this to work through regualr shape tweening, (which is lame! :)). I really want to know how to do this right so I can actually sleep tonight, last night was really bad. ☹

thx in adv.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 2:18am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/5 "2004-07-30T02:18:43Z")

</div>

when working with dynamic names of clips it helps flash out if you use paths to the clips, in othe words try this,(assuming these clips are created on the root layer):  
for(i=2; i\<=10; i++){  
duplicateMovieClip(mask0\_mc,“mask”+i+"\_mc", 1)  
j=i-1  
trace(\_root[“mask”+j+"\_mc"].\_width)  
trace(“mask”+j+"\_mc")  
\_root[“mask”+i+"\_mc"].\_width = \_root[“mask”+j+"\_mc"].\_width\*1.1  
\_root[“mask”+i+"\_mc"].\_x = \_root[“mask”+j+"\_mc"].\_x - \_root[“mask”+i+"\_mc"].\_width;  
}

PS this answers the question you had back in April…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 6:37am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/6 "2004-07-30T06:37:55Z")

</div>

A combination of lunatic’s and paradox’s answers

```auto
for (i=2; i<=10; i++) {
	duplicateMovieClip("mask0_mc", "mask"+i+"_mc", i);
	j = i-1;
	trace(this["mask"+j+"_mc"]._width);
	this["mask"+i+"_mc"]._width = this["mask"+j+"_mc"]._width*1.1;
	this["mask"+i+"_mc"]._x = this["mask"+j+"_mc"]._x-this["mask"+i+"_mc"]._width;
}

```

works, but gives an (obvious) undefined for the first width, cause there’s no mask1\_mc:)

```auto
for (i=1; i<=9; i++) {
	duplicateMovieClip("mask0_mc", "mask"+i+"_mc", i);
	j = i-1;
	trace(this["mask"+j+"_mc"]._width);
	this["mask"+i+"_mc"]._width = this["mask"+j+"_mc"]._width*1.1;
	this["mask"+i+"_mc"]._x = this["mask"+j+"_mc"]._x-this["mask"+i+"_mc"]._width;
}

```

might be better;)

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 6:58am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/7 "2004-07-30T06:58:51Z")

</div>

And to avoid multiple associative array referencing (and to make the code nicer):

```auto

  for (i=1; i<=9; i++) {
      var imc = mask0_mc.duplicateMovieClip("mask"+i+"_mc", i);
      var jmc = this["mask"+(i-1)+"_mc"];
      trace(jmc._width);
      imc._width = jmc._width*1.1;
      imc._x = jmc._x-imc._width;
  }
  

```

\*Thanks for spotting scotty 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 7:07am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/8 "2004-07-30T07:07:45Z")

</div>

You’re right as allways:lol:  
but

```auto
mc._width = jmc._width*1.1;
mc._x = jmc._x-mc._width;

```

shouldn’t that be

```auto
imc._width = jmc._width*1.1;
imc._x = jmc._x-imc._width;

```

??

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 7:09am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/9 "2004-07-30T07:09:14Z")

</div>

Lol yup, I changed mc to imc after jmc came in, forgot to change those 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 7:18am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/10 "2004-07-30T07:18:35Z")

</div>

:lol:I thought it would be something simple like that, but couldn’t resist:lol:

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 9:17am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/11 "2004-07-30T09:17:23Z")

</div>

Thanks for all the help y’all 🙂 everything is tracing to the output and the code looks much nicer!  
I have run into another problem regarding this that im not sure how to solve.

The point of all this is to create a mask for a dynamically loaded jpg. this was going to be done by creating squares that gradually got bigger and tweened left to right, slowly revealing the image (hence the scaling and setting of x values).

Im using Robert Pennings tweening class (awesome tiem saver!) to move the mask0\_mc along the stage, hoping that the recently duplicated mc’s would follow, but they do not. \>\_\<

I think it is due to the fact that the duplicated mask1\_mc cant find the mask0\_mc to follow along the \_x axis :? I tried putting an if statement inside the for loop with a condition i = 1, ie-setting the mask0\_mc in motion as the other clips are being created, but this was a system resource no-no ☹

Any ideas? :?

Thanks again for all your help…really helping me understand these \*\*\*\* for loops :D.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 9:40am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/12 "2004-07-30T09:40:33Z")

</div>

Here’s an example with Voets’ golden formula

```auto
MovieClip.prototype.easeTo = function(tar) {
	this.onEnterFrame = function() {
		this._x = tar-(tar-this._x)/1.1;
		if (Math.abs(this._x-tar)<1) {
			this._x = tar;
			delete this.onEnterFrame;
		}
	};
};
for (i=1; i<=9; i++) {
	var imc = mask0_mc.duplicateMovieClip("mask"+i+"_mc", i);
	var jmc = this["mask"+(i-1)+"_mc"];
	imc._width = jmc._width*1.1;
	imc._x = jmc._x-imc._width;
	imc.easeTo(400);
}

```

Replace the easeTo with Robert Penners function (in the for loop) 😉

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 9:50am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/13 "2004-07-30T09:50:22Z")

</div>

dang, lots of nice stuff in there! 😃

is there a significance to “prototype?” I also didnt know you could delete onEnterFrames! that is awesome! 😛 I actually ran into that problem and had to rewrite to setInterval to try to solve it.  
Is it possible to delete functions as well? or maybe just stop them?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 10:03am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/14 "2004-07-30T10:03:23Z")

</div>

ahh, just tried it, the dup’ed MC’s still arent following across the stage ☹

this is the processer intensive for loop that, once the script that is making the movie move slowly, actually moves the dup’ed MC’s (although it loops them :?)

for (i=1; i\<=9; i++) {  
if(i=1){  
mask0\_mc.slideTo(833, 301, 3, “easeOutQuad”);  
}  
var imc = mask0\_mc.duplicateMovieClip(“mask”+i+"\_mc", i);  
var jmc = this[“mask”+(i-1)+"\_mc"];  
imc.\_width = jmc.\_width\*1.1;  
imc.\_x = jmc.\_x-imc.\_width;  
imc.slideTo(833, 301, 3, “easeOutQuad”);  
}

its the if statement that makes the processor freak…if i could say something like: start the for loop and before anything is processed send the first mc out for the rest to follow :?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 10:56am UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/15 "2004-07-30T10:56:13Z")

</div>

```auto
if(i==1){

```

😉

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 3:38pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/16 "2004-07-30T15:38:52Z")

</div>

It’s like Christmas! I go to sleep and when I wake up everything is fixed and beautiful! Thanks eveyone for picthing in and helping here! I never would have come up with those beautiful equations by Voets, Scotty and Paradox!

:thumb:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 4:57pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/17 "2004-07-30T16:57:29Z")

</div>

hahah, man, thats a sure sign that you have been working on something for too long 😉 unfortunately its still not working ☹

here is what ive got.  
\<actionscript\>  
for (i=1; i\<=9; i++) {  
if(i==1){  
mask0\_mc.slideTo(861, 301, 3, “easeOutQuad”);  
}  
var imc = mask0\_mc.duplicateMovieClip(“mask”+i+"\_mc", i);  
var jmc = this[“mask”+(i-1)+"\_mc"];  
imc.\_width = jmc.\_width\*1.2;  
imc.\_x = jmc.\_x-imc.\_width;  
imc.slideTo(imc.\_x, 301, 3, “easeOutQuad”);  
}  
\</actionscript\>

so on the for iteration of the loop it send the mc that is being dup’ed moving, the rest unfortunately dont follow :? So close I cant almost taste it! 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 30, 2004, 7:22pm UTC](https://forum.kirupa.com/t/pulling-my-hair-out-over-nothing/59255/18 "2004-07-30T19:22:10Z")

</div>

```auto

for (i=1; i<=9; i++) {
	**if(i==1)** {
		mask0_mc.slideTo(861, 301, 3, "easeOutQuad");
	}
        var imc = mask0_mc.duplicateMovieClip("mask"+i+"_mc", i);
        var jmc = this["mask"+(i-1)+"_mc"];
        imc._width = jmc._width*1.2;
        imc._x = jmc._x-imc._width;
        imc.slideTo(imc._x, 301, 3, "easeOutQuad");
}

```

Seems to me in this for loop that i is only 1 once . . .

:hr:
