Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    119
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to make an action to "go to next label"?

    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:



    Code:
    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--;
    
    }

  • #2
    New Coder
    Join Date
    Aug 2008
    Location
    Ottawa, Canada
    Posts
    12
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #3
    New Coder
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you want to goto the next frame then just use _root.gotoAndPlay(_root._currentFrame+1)

  • #4
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    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
    Last edited by itsallkizza; 10-20-2008 at 02:20 AM. Reason: spelling

  • #5
    New to the CF scene
    Join Date
    Oct 2008
    Location
    Tennessee
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How about this?

    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.:

    Code:
    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?

    Code:
    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;
    	}
    }


  •  

    Posting Permissions

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