|
-
[F8] Pausing frames in a movie clip?
I've got a movie clip where I'm picking a random number and loading a corresponding image, and my ActionScript on the first frame of the movie clip is this-
startTime = getTimer();
this.onEnterFrame = function () {
currentTime = getTimer();
if(currentTime-startTime > 1000) {
var frontr:Number=random(44);
while(frontr == 0){
frontr=random(44);
}
this.loadMovie('http://www.tiffanydavisphotography.com/gallery/photo'+frontr+'.jpg');
}
}
It runs through there once, and loads an image, but I want it to keep loading images every "x" (or 1000) seconds. How do I keep it running?
-
Ryan Thomson
instead of onEnterFrame and getTimer, maybe use setInterval, that way every time it reaches 1000 you could jsut reset it back to 0 and it would use less resources which is always a plus
-
-
Ryan Thomson
one sec, i'll post an example
-
Ryan Thomson
k here's a down and dirty example, should give you the idea anyways and it does work too 
Code:
var count:Number = 0;
var frontr:Number = random(44);
this.createEmptyMovieClip("container", this.getNextHighestDepth());
container.loadMovie('http://www.tiffanydavisphotography.com/gallery/photo'+frontr+'.jpg');
function executeCallback():Void {
var frontr:Number = random(44);
trace(count + " seconds so far..");
count++;
if(count >= 1000){ // change 1000 to how many seconds you want between slides
count = 0;
if(frontr == 0){
frontr=random(44);
}
container.loadMovie('http://www.tiffanydavisphotography.com/gallery/photo'+frontr+'.jpg');
}
}
// 1000 equates to once/second so you prlly don't need to change this
intervalId = setInterval(this, "executeCallback", 1000);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|