# Flash next / prev frame continously actionscript



## Gesp (Nov 29, 2008)

Hi

I was looking for an actionscript that executed the action of going to the previous / next frame, but continously. As if I had a lot of frames and the user wouldn`t need to be always clicking, just mantaining the button pressed and it automatically wandered the frames.

Can anyone help me?


----------



## -Fabez- (Jul 28, 2008)

So you want the Actionscript for a button, that will make the playhead go forward or backwards continuously while pressed ?


----------



## Gesp (Nov 29, 2008)

Sleeping is the instance name right?


----------



## -Fabez- (Jul 28, 2008)

I think you are looking at my signature, as I did not post any code  However here is a working example below.


```
var Navigation:Number = 2;
Forward_mc.onPress = function() {
	Navigation = 3;
};
Forward_mc.onRelease = function() {
	Navigation = 2;
};
_root.onEnterFrame = function() {
	switch (Navigation) {
		case 1 :
			_root.gotoAndStop(_root.prevFrame);
			//_root.gotoAndPlay(_root.prevFrame())
			break;
		case 2 :
			break;
		case 3 :
			_root.gotoAndStop(_root.nextFrame);
			//_root.gotoAndPlay(_root.nextFrame())
			break;
	}
};
```
If you have any questions, just ask


----------



## Gesp (Nov 29, 2008)

hmm, I tried it on an actions frame, linking the names with a button but it did not work. What exactly could this code do? I don`t understand the "case" process


----------



## -Fabez- (Jul 28, 2008)

I will add comments for you. Do you want to attach the file, and have me look at ?


----------



## -Fabez- (Jul 28, 2008)

Here is the updated code, with comments. I also changed two lines of code.


```
/*Create the navagation variable
it can be one of three values
1 = Backward
2 = Stay at current frame
3 = Forward*/
var Navigation:Number = 2;
//When Forward_mc is pressed the function is executed
Forward_mc.onPress = function() {
	//The navigation variable is set to 3
	Navigation = 3;
};
//When Forward_mc is released the function is executed
Forward_mc.onRelease = function() {
	//The navigation variable is set to 2
	Navigation = 2;
};
//Every time the _root timeline enters a frame the function is executed
_root.onEnterFrame = function() {
	//Switch means use this variable and compare it to each one of the case's
	switch (Navigation) {
		//If Navigation is equal to 1, go to the previous frame
		case 1 :
			Holder_mc.prevFrame();
			break;
		//If Navigation is equal to 2, do nothing
		case 2 :
			break;
		//If Navigation is equal to 3, go to the next frame
		case 3 :
			Holder_mc.nextFrame();
			break;
	}
};
```


----------



## Gesp (Nov 29, 2008)

yep, its working now, I did something wrong previously because I didn`t understand the coding very well. Although I have enough expirience on actionscript to build my one coding lines and methods, I had never known of that "case" method.

It`s a really nice and simple process.

Thanks , I just can`t/won`t stop learning from you guys

Sorry about my "stupidness" when I though your sig was the coding response... I just couldn`t stop laughing at me


----------



## -Fabez- (Jul 28, 2008)

Glad to hear that it is working  Don't worry about it we all make mistakes, if you need any more Flash help, then feel free to ask


----------

