-
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???
-
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.
-
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! :mrpimp:
-
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.
-
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!
-
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?
-
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?
-
As long as it isn't huge in filesize, fire away ... zip it and attach it to your post.
-
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! :confused: