View Full Version : Why isn't this setInterval working??
fasterthanlight™
May 10th, 2005, 03:58 PM
I'm trying to create a wipe, where a bar expands vertically from the top to the bottom. This was accomplished with a motion tween. Now, I'm trying to use AS to duplicate that one bar across the screen, and this is done inside a movieclip, and the movieclip is on the main stage and it is setMask(my_mc); to reveal an image beneath.
Here's the code I'm using:
totalBars = Math.round(Stage.width/bars._width);
i = 0;
duplicate = function () {
if (i <= totalBars) {
i += 1;
bars.duplicateMovieClip("bars"+i, this.getNextHighestDepth());
this["bars"+i]._x = i*bars._width;
}else{
clearInterval(intervalID);
}
};
var intervalID = setInterval(duplicate, 10);
But it doesn't work!
The_Protector
May 10th, 2005, 04:23 PM
try dropping the "var"
fasterthanlight™
May 10th, 2005, 04:28 PM
That doesn't fix it. :(
fasterthanlight™
May 10th, 2005, 04:29 PM
Now, if i throw in a trace("IS IT WORKIGN???"); here:
totalBars = Math.round(Stage.width/bars._width);
i = 0;
duplicate = function () {
if (i <= totalBars) {
i += 1;
bars.duplicateMovieClip("bars"+i, this.getNextHighestDepth());
this["bars"+i]._x = i*bars._width;
trace("IS THIS WORKING???");
}else{
clearInterval(intervalID);
}
};
var intervalID = setInterval(duplicate, 10);
It traces "IS THIS WORKING" 12 times, (correct amount), so it's doing the function, and stopping after 12, but theres no duplicating action going on.
Lindquist
May 10th, 2005, 04:44 PM
Post or e-mail me your .fla and I'll take a look at it.
3pinter
May 10th, 2005, 04:47 PM
totalBars = Math.round(Stage.width/bars._width);
i = 0;
duplicate = function () {
if (i <= totalBars) {
i += 1;
var bars = bars.duplicateMovieClip("bars"+i, this.getNextHighestDepth());
bars._x = i*bars._width;
trace("IS THIS WORKING???");
}else{
clearInterval(intervalID);
}
};
var intervalID = setInterval(duplicate, 10);
Does this work?
Else: try replacing this.getNextHigestDepth() by "i"... perhaps that's bugging you.
3Pinter
:smirk:
fasterthanlight™
May 10th, 2005, 11:34 PM
The Fla as requested :)
(http://www.jamieroy.com/barWipe.fla.zip)
Lindquist
May 10th, 2005, 11:59 PM
Hope this helps.
fasterthanlight™
May 11th, 2005, 12:02 AM
Linquist, you get my vote for anything that you are nominated for. :azn:
Works like a charm
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.