PDA

View Full Version : Stopping a loop after a certain number of repetitions


cableray
11-08-2006, 06:10 PM
I got the following code stock and wanted to make it stop after a specified number of repetitions. The code is for a masking effect for a series a pictures. could someone take a look at it and tell me how to get it to stop after it has displayed all the pictures a specified number of times? Also, it would be nice to be able to specify a pause between each transition, right now i just have it continue the transition beyond the viewable area. I have some applescript and c++ experience, but not really any actionscript. Thanks!

//EDITABLE VARIABLES
waitSeconds = 6;
imageNumber = 4;
areaWidth=(160*3);
areaHeight=(280+0);
//STOCK CODE
time1 = getTimer();
var cnt:Number = 1;
var p_cnt:Number = 1;
bgpic.setMask(mask);
_root.onEnterFrame = function() {
now1 = getTimer();
if (now1>=(time1+(waitSeconds*1000))) {
_root.calis = 1;
time1 = getTimer();
cnt++;
bgpic.duplicateMovieClip("bgpic"+cnt, _root.getNextHighestDepth());
mask.duplicateMovieClip("mask"+cnt, _root.getNextHighestDepth());
shine.duplicateMovieClip("shine"+cnt, _root.getNextHighestDepth());
buts.swapDepths(_root.getNextHighestDepth());
panel.swapDepths(_root.getNextHighestDepth());
_root["mask"+cnt]._x = 0;
_root["mask"+cnt]._y = bgpic._y;
_root["shine"+cnt]._x = 0;
_root["shine"+cnt]._y = bgpic._y;
_root["bgpic"+cnt]._x = 0;
_root["bgpic"+cnt]._y = bgpic._y;
if (p_cnt == imageNumber) {
p_cnt = 0;
for (i=cnt-10; i<(cnt-1); i++) {
_root["shine"+i].removeMovieClip();
_root["mask"+i].removeMovieClip();
_root["bgpic"+i].removeMovieClip();
}
}
p_cnt++;
_root["bgpic"+cnt].attachMovie("p"+p_cnt, "p"+p_cnt, 1);
_root["bgpic"+cnt].setMask(_root["mask"+cnt]);
}
};
stop();

anonymous
11-08-2006, 08:46 PM
Attach some .fla.