A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Next/Previous buttons > AS2

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    18

    [F8] Next/Previous buttons > AS2

    Hello,

    I am trying to create a sort of book type thing in flash. I would like to have a "next" button that when clicked will go over to the next body of text to be read, as well as a previous button that will go back to what was just read. I would also like a "back to beginning" button.

    I know how to do the "gotoAndPlay (1)" type thing on a button. However, would I have to add a new button on each of the text parts? Or can I put it all on the same buttons?

    For example: (I know this isn't real code or anything, just trying to describe)

    if on text one > got to text two
    if on text two > go to text three
    if on text nine > go to text ten
    if on text ten > go to (end here so next button disabled, or changed to 'back to start')

    Let me know,
    Infamous D

    PS: Using ActionScript 2.0

  2. #2
    OGC creativeinsomnia's Avatar
    Join Date
    Apr 2001
    Location
    mn
    Posts
    658
    You could just use one set of buttons for next/previous. Havent tried this out but give this a go.

    use this for the next button : gotoAndPlay(_currentframe +1)

    use this for the previous button : gotoAndPlay(_currentframe -1)

  3. #3
    Actionscript Samurai
    Join Date
    Jan 2008
    Location
    JAPAN
    Posts
    2
    Hello : )

    How about this code?

    //AS2.0
    next_btn.onRelease = goNext;
    prev_btn.onRelease = goPrev;

    function goNext():Void{
    changePage(_currentframe+1);
    }
    function goPrev():Void{
    changePage(_currentframe-1);
    }
    function changePage(page:Number):Void{
    gotoAndStop(page);
    prev_btn._visible = page==1 ? false : true;
    next_btn._visible = page==_totalframes ? false : true;
    }
    Last edited by AS Samurai; 01-27-2008 at 12:13 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2007
    Posts
    18
    Ok, I put the code in and finally got it to where it didn't give me an error. The code works, it just plays one frame at a time. If you click really fast, you can actually see the animation! LOL. Do I need to change anything in the code? I labeled the beginning frames, if that makes any difference.

    Each thing has an animation on it, so the frames are not side by side.... What I need is something like "go to the next labeled frame" and not the next frame.

    Deadra

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    18
    I tried making several movie clips to jump from one movie clip to the next, but the clips just loop. I tried adding stop(); but that did not work....

    Here is what I am trying to do:

    I have my flash scene. When you first view it, a block of text fades into view. then you click next and that block of text fades out, and then the next block of texts fades in. This repeats until the end of the "story" and you can hit the "back" button to read the story again. (My back button works great, btw....>.>).

    When I use the code given, it only advances to the next frame, which only makes the current text time a little because it is going into the next frame that begins the fade out. If you keep clicking, it fades a little more by each frame. I need the script to take the user to the next LABEL, not next frame. I found various codes on the net, but I couldn't get any of them to work....T.T

    Deadra

  6. #6
    Senior Member
    Join Date
    Aug 2001
    Location
    Fort Wayne Indiana
    Posts
    156

    I too really need this to play a movieclip backwards

    Is there a way to "loop" this changePage function to keep stepping back or forward through the frames?
    http://www.flashfrog.com

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    1

    easy as heck

    Lol...you guys must be kidding. Yes, there is a way to loop the changePage function: you have to redefine the function itself. If the effect you're looking for is going back and/or next via the _currentframe +1/-1 script all you have to do is replace changePage with gotoAndPlay. The code would look something like this:

    //AS2.0
    next_btn.onRelease = goNext;
    prev_btn.onRelease = goPrev;

    function goNext():Void{
    gotoAndPlay(_currentframe+1);
    }
    function goPrev():Void{
    gotoAndPlay(_currentframe-1);
    }
    //

    Now your only problem is how you set the stage for your back button. You'll probably have to manually count the number of frames between the animations and modify your code.

    function goPrev():Void{
    gotoAndPlay(_currentframe-x); <<where x is your number
    }

    Anyway...thanks for the code guys. Works great !

  8. #8
    Junior Member
    Join Date
    Sep 2010
    Posts
    1
    Hey, people. I'm terrible at flash. PLEASE ADDRESS ME LIKE I'M FIVE! Walk me the smallest steps out there, from making the button to layers to... everything. I need help and I'm slow xD
    I'm using Adobe Flash CS4 and trying to make a flash comic, a basic setup with a drawing, then a button that moves us on to the next page, and then a button that moves you onto the next page, etc. I've been wandering around the web for an hour and visited the heck out of all possible tutorials, which for the most part are either lost on me concerning the process of which people are directing me to do things, or not right for my computer.
    I thought this was going to be a lot simpler, and apparently I WAS VERY WRONG XD
    Or at least it's not simple for people like me, with brains the size of pennies *shot*

    If anyone responds to this I'll be very, very grateful. I'd love to bring my comic into a controlled slideshowish format...

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