Pulling my hair out over nothing?

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 :frowning:

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 :? :slight_smile:

thx in advance for any help.

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:

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

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?

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. :frowning:

thx in adv.

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…

A combination of lunatic’s and paradox’s answers

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:)

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(-:

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


  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 :wink:

You’re right as allways:lol:
but

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

shouldn’t that be

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

??

scotty(-:

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

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

scotty(-:

Thanks for all the help y’all :slight_smile: 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 :frowning:

Any ideas? :?

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

Here’s an example with Voets’ golden formula

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) :wink:

scotty(-:

dang, lots of nice stuff in there! :smiley:

is there a significance to “prototype?” I also didnt know you could delete onEnterFrames! that is awesome! :stuck_out_tongue: 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?

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

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 :?

if(i==1){

:wink:

scotty(-:

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:

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

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! :slight_smile:


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: