You need to dispense with the for loop (which creates all your duplicates in
one shot) and use setInterval to call a function instead (dupMC() below.)
I've made some other changes (commented) to help get you closer to your
goal.
<code>
var ln:Number = 30;
var spacer:Number = 0;
var listeMC = new Array();
//separate the 'container' from the 'clip-Number' MovieClips it holds
this.createEmptyMovieClip("container", this.getNextHighestDepth());
var dupee:MovieClip = setUpContainer(); //create our seed movie
listeMC.push(dupee); //get our seed movie (container.clip-0) into the list
var i:Number = 1; //initialize the counter
function dupMC() {
//the 'tempMC' reference need not exist outside this function's
scope
var tempMC:MovieClip = dupee.duplicateMovieClip("clip-" + i, i);
tempMC._y = (tempMC._height + spacer) * i;
tempMC._alpha = ln/i*10; //a more flexible formula
listeMC.push(tempMC); //add the duplicate to the list
//turn off the interval when done
if (i == ln) {
//we end up with ln+1 child clips (clip-0 thru clip-ln)
//in this case container has 31 children
clearInterval(intervalID);
}
i++;
}
var intervalID:Number = setInterval(dupMC, 100); //one-tenth of a second
function setUpContainer():MovieClip {
var mc:MovieClip = container.createEmptyMovieClip("clip-0",
container.getNextHighestDepth());
mc.lineStyle(1, 0xffffff, 0);
mc.beginFill(0x0000000, 100);
mc.moveTo(10, 0);
mc.lineTo(10, 0);
mc.lineTo(10, 10);
mc.lineTo(0, 10);
mc.lineTo(0, 0);
mc._x = 1;
mc._y = 0;
mc.endFill();
return mc;
}
</code>
HTH
-Keith
http://home.mn.rr.com/keithreinfeld
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of hervé hubert
Sent: Saturday, July 01, 2006 10:14 AM
To: [email protected]
Subject: [Flashcoders] duplicateMovie / setInterval problem
Hi I'm trying to duplicate a MC by adding a time delay with setInterval
It
doesn't seems to work can anyone help?
Thanks alot.
//Code
var container:MovieClip = setUpContainer(); var ln:Number = 30; var
spacer:Number = 0; var newMC:MovieClip;
var listeMC = new Array();
for (var i=1 ; i<=30; i++)
{
newMC = container.duplicateMovieClip("clip-"+i,
i+10);
newMC._y = (newMC._height + spacer) * i;
newMC._alpha -= i*4;
clearInterval(intervalID);
}
var intervalID =setInterval(setUpContainer,1);
function setUpContainer():MovieClip {
var mc:MovieClip = this.createEmptyMovieClip("container",
this.getNextHighestDepth());
mc.lineStyle(1, 0xffffff, 0)
mc.beginFill(0x0000000, 100);
mc.moveTo(10,0);
mc.lineTo(10,0);
mc.lineTo(10,10);
mc.lineTo(0,10);
mc.lineTo(0,0);
mc._x = 1;
mc._y = 0;
mc.endFill();
return mc;
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com