A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Pausing frames in a movie clip?

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    27

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

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    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
    Evolve Designs Interactive Media
    the natural selection

  3. #3
    Junior Member
    Join Date
    Mar 2007
    Posts
    27
    How do you use that?

  4. #4
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    one sec, i'll post an example
    Evolve Designs Interactive Media
    the natural selection

  5. #5
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    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);
    Evolve Designs Interactive Media
    the natural selection

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center