View Full Version : how to make an action to "go to next label"?
alapimba
10-02-2008, 06:59 PM
HI.
I want to do a slide show with a button to go forward. How can i make a button go to the next label?
I tryed this but it's not working for some reason:
count=0;
myArr=["1","2","3","4","5","6"];
nextButton.onRelease=function(){
_root.gotoAndStop(myArr[count+1]);
count++;
}
prevButton.onRelease=function(){
_root.gotoAndStop(myArr[count-1]);
count--;
}
Lucidity
10-03-2008, 01:15 PM
Why even use an array? You could just as easily just use a counter.
Also, if you do it the way you currently have it, once you get past label 6, it will stop working if they try to keep going forward, and there is nothing keeping it from going into the negatives. It would be easier to just use a counter start at 1 I think, and put an if statement on the prevButton saying "counter --, If counter = 0, counter = 6" and an if statement on the nextButton saying "counter ++ then If counter = 7, then counter = 1"
That might work better. I'm not sure exactly what you're doing, but it would definitely be easier.
-Fabez-
10-13-2008, 05:32 PM
If you want to goto the next frame then just use _root.gotoAndPlay(_root._currentFrame+1)
itsallkizza
10-20-2008, 02:20 AM
alapimba: you're code would work if either a) the array was integers instead of strings, or b) your frames had titles "1", "2", "3" etc.
but as the previous two mentioned, that's not solid or efficient coding and if you just want to move from one frame to the one right next to it and so on, use their suggestions
rebeltech81
10-27-2008, 09:36 PM
All you need to do just for simple back/next navigation is use prevFrame() inside your prevButton.onRelease and nextFrame() with your nextButton.onRelease function.:
prevButton.onRelease = function():Void
{
prevFrame();
}
nextButton.onRelease = function():Void
{
nextFrame();
}
But to make things a bit more friendly to your user, how about making the back button invisible on the first page and setting the next button to take you back to the first page if you are on the last one?
prevButton.onRelease = function():Void
{
prevFrame();
}
nextButton.onRelease = function():Void
{
// if the current frame we're on is the last one,
// have the next button take us to the first frame
if (_currentframe == _totalframes)
{
gotoAndStop(1);
}
// otherwise go to the next page
else
{
nextFrame();
}
}
this.onEnterFrame = function():Void
{
if (_currentframe == 1)
{
prevButton._visible = false;
}
else
{
prevButton._visible = true;
}
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.