A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: simple "go next" action script?

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    13

    simple "go next" action script?

    I am trying to create a simple slide show, i have set up the different slides with labels and i want one button to go to the next slide and one to go to the pervious.

    It seems simple but i cant seem to find a code that works.
    something like...

    on release go to and play "next"

    there are too many slides to put in the individual name of each label. so a simple next button would be ideal.

    any ideas?

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    are you moving the playhead along a timeline ?
    if so, use -
    nextFrame(); // goes to the next frame and stops
    prevFrame(); // goes to the previous frame and stops

    ActionScript 2.0 Language Reference >
    ActionScript language elements > Global Functions > nextFrame function

    an example of controlling the timeline with keypresses is shown here.

    hth

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    hi thanks for ur reply. I need the playhead to go to a specific label because not all labels are the same number of frames apart. its just a simple slide show, but some of the slides need to run for more frames than others, therefore if i could get the playhead to jump to the next label that would be ideal. there are too many to type in individually the label name.
    any ideas?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    if you are going to navigate by labels, at some point you are going to have to
    bite the bullet and make a list of all of the labels in use

    prolly easiest to use an array and a variable

    arrLabels = ["label1", "label2","label3"......]; // array of labels
    var id =0; // variable

    next_btn.onRelease = function(){
    id <= arrLabels.length ? id++ : null; // don't go past last label in array
    gotoAndPlay(arrLabels[id]);
    }

    prev_btn.onRelease = function(){
    id > 0 ? id--: null ; // don't go past first label in array
    gotoAndPlay(arrLabels[id]);
    }

  5. #5
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    im a beginner so thats looks really complicated to me. if you have a spare minute can u explain it a bit more. thanks a lot!!!!

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    variable id starts at zero - id=0;

    next button has id++, this is id = id+1, so id=1;
    in the array - arrLabels[1] = "label2"
    so the button release sends the timeline to "label2"

    previous button has id--, this is id = id-1, so if id was 5, it becomes 4
    in the array - arrLabels[4] = "label5"
    so the button release sends the timeline to "label5"

    the ternary operators < ? : > are used to prevent the variable id
    going outside of the limits of the array

    any help

  7. #7
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    great! thanks a lot!!!!

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you're welcome

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