dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Interval doesnt work?

  1. #1
    Senior Member
    Join Date
    Jul 2004
    Location
    outside Philly
    Posts
    154

    Interval doesnt work?

    I am working on a slideshow piece where you would press the button once to start and press again to stop. I set the variable in the main section archslideshow="off"
    All the other variables that are in the code are being called correctly so dont worry about those. This is the code I am working with

    Code:
    on(release){
    if(archslideshow=="off"){
    	trace(archslideshow+ " off");
    	function slideshowgo(){
    	newnum=_currentframe-119+1;
    	if(newnum<_root.totalArchitecture-1){
    		newsection=_currentframe+1;
    		cover.gotoAndPlay("close");
    		trace(newsection+" is a +1");
    		trace(newnum+" newnum");
    	}else{
    		newsection=119;
    		cover.gotoAndPlay("close");
    		trace(newsection+" end back to beginning");
    		trace(newnum+" newnumend");
    	}
    	}
    		newnum=_currentframe-119+1;
    		if(newnum<_root.totalArchitecture-1){
    			newsection=_currentframe+1;
    			cover.gotoAndPlay("close");
    			trace(newsection+" is a +1");
    			trace(newnum+" newnum");
    		}else{
    			newsection=119;
    			cover.gotoAndPlay("close");
    			trace(newsection+" end back to beginning");
    			trace(newnum+" newnumend");
    	}
    	archslideshow="on";
    	var intervalID:Number = setInterval(slideshowgo,4000);
    }else if(archslideshow=="on"){
    	trace(archslideshow+ " on");
    	archslideshow="off";
    	clearInterval( _root.intervalID );
    }
    }
    What is happening is that the interval is only running once (jumps to next frame) then it stops and I need to press the button twice to get it to start again.

    If I remove the archslideshow coding the slideshow works perfectly but I need to set it so that if they press the button again it stops.

    This is a sample of the trace I am getting - you'll notice I need to press the button to off to get it to start again.

    Code:
    off off
    127 is a +1
    8 newnum
    on on
    off off
    128 is a +1
    9 newnum
    119 end back to beginning
    10 newnumend
    120 is a +1
    1 newnum
    121 is a +1
    2 newnum
    122 is a +1
    3 newnum
    121 is a -1
    4 newnum-1
    120 is a -1
    3 newnum-1
    on on
    off off
    121 is a +1
    2 newnum
    on on
    off off
    122 is a +1
    3 newnum
    on on

    Any help is really appreciated.

    Thanks,
    Randy

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Location
    outside Philly
    Posts
    154
    actually what is happening is that the interval is never being called, the jump is coming from the bottom part of the code where it has the same code so that it goes as soon as you press the button.
    Any ideas why the interval is not being called.

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