dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: scene navigation help

  1. #1
    eLearning Dev Monkey
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    28

    scene navigation help

    hello

    i have a problem with the use of prevScene() and nextScene().

    my situation is this:

    i have some graphics and the navigation buttons in a movie clip. on each scene, the clip is placed onto the screen. the navigation buttons call my functions

    nextSlide(), prevSlide() etc...

    which, among other things calls prevScene(), nextScene() etc. my custom functions are placed in the _root of my first scene.

    in scene one, the buttons work fine, but in the second scene, the next button makes scene 2 replay, rather than skipping to the next scene.

    any ideas???

  2. #2
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    Specify a scene name where possible - using nextScene() and prevScene() is always a gamble. Even better, make and use labels instead of scenes ... scenes have a habit of screwing up when refered to from nested timelines.
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  3. #3
    eLearning Dev Monkey
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    28
    Code:
    function nextSlide() {
    	if(currentSlide < totalSlides) {
    		destinationSlide = ["slide" + [currentSlide + 1]];
    		trace(destinationSlide);
    		_root.gotoAndPlay(destinationSlide);
    	}
          }
    {
    okay here is what i want to do, my nav button calls this function, i have labelled the first frame of each slide: slide1, slide2 etc

    help please!

  4. #4
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    Code:
    function nextSlide() {
     if(currentSlide < totalSlides) {
      _root.gotoAndPlay("slide" + (currentSlide + 1));
     }
    }
    This SHOULD work (no promises) - it won't increase the value of currentSlide (I'm presuming that is done somewhere else), and I think it assumes that the values for currentSlide and totalSlides are in the main timeline. I don't know because I haven't seen your FLA ... I can only go on what you pasted above.
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  5. #5
    eLearning Dev Monkey
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    28
    Code:
    function prevSlide() {
    	if(_root.currentSlide > 1) {
    		_root.gotoAndPlay("slide" + (_root.currentSlide - 1));
    		_root.currentSlide --;
    	}
    }
    
    function nextSlide() {
    	if(_root.currentSlide < _root.totalSlides) {
    		_root.gotoAndPlay("slide" + (_root.currentSlide + 1));
    		_root.currentSlide ++;
    	}
    }
    okay this is in a mc with the nav buttons, which in turn is on the main timeline. currentSlide and totalSlides are declared and initialised on the first frame of slide1. for some reason, currentSlide is incremented/decremented properly. can variables be passed over scenes?

    thanks for the help so far!
    Last edited by vince_mmc; 10-14-2002 at 10:39 AM.

  6. #6
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    Variables don't need to be passed between scenes ... scenes are just a construct to make it easier to divide lots of content into managable chunks. Your variables are set in the main timeline (_root), you can access them from anywhere (any scene or movieClip) by addressing them as _root.currentSlide and _root.totalSlides. So, your question is irrelevant in the sense that scenes do not come into the equation.

    Does your code work now?
    Last edited by garbage; 10-14-2002 at 10:48 AM.
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  7. #7
    eLearning Dev Monkey
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    28
    it'll work if the buttons, and their functions are on the main timeline., but if i try and put the functions and buttons in their own timeline, the currentSlide tracking goes to pot. could i send you the .fla?
    Last edited by vince_mmc; 10-14-2002 at 10:53 AM.

  8. #8
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    As long as it isn't huge in filesize, fire away ... zip it and attach it to your post.
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  9. #9
    eLearning Dev Monkey
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    28
    not to worry, just had a dev meeting, and the powers that be have decided to opt to update the non-streaming, coding nightmare that is the old version.

    cheers anyway!

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