not quite, goCheckBackward = function() { if ( index <= 0 ) { index = max; } index--; gotoAndPlay(frames[index]); trace(frames[index]); }
you´d need to move the index-- between the if and goto() or otherwise you´d run out of bounds, since his Array starts at 0 and ends at max-1. I´ve also changed the if-condition, otherwise you´d never reach frames[0] Greatings, André -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Adrian Lynch Gesendet: Sonntag, 26. Februar 2006 17:01 An: Flashcoders mailing list Betreff: RE: [Flashcoders] Navigating between labels? Scripting help: goCheckBackward would be the opposite of goCheckForward: goCheckForward = function() { if ( index >= max ) { index = 0; } gotoAndPlay(frames[index]); trace(frames[index]); index++; } goCheckBackward = function() { if ( index < 1 ) { index = max; } gotoAndPlay(frames[index]); trace(frames[index]); index--; } Untested, but looks ok to me. Adrian -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Michael Hulse Sent: 26 February 2006 12:55 To: Flashcoders mailing list Subject: [Flashcoders] Navigating between labels? Scripting help: Hey all... I need some help with the below code... I am trying to set-up a dynamic way to jump from label to label on the main timeline of my animation... Well, here is what I got so far... Still working on it, and it prob is not optimal, but maybe you all will have some suggestions: /* Initialize index: */ var index = 1; /* Declare var frames as an array: */ var frames:Array = new Array(); /* Pop array with scene labels: */ var frames = ["scene1", "scene2", "scene3"]; /* Get length of array: */ var max = frames.length; /* Attach function to forward button: */ _root.forward.onRelease = function() { goCheckForward(); } /* Attach function to backward button: */ _root.backward.onRelease = function() { goCheckBackward(); } goCheckForward = function() { /* If index is >= array length, zero-out var index: */ if(index >= max) { index = 0; } gotoAndPlay(frames[index]); trace(frames[index]); index++; /* add one to var index */ } /* Still working on this function... buggy atm. Suggestions? */ goCheckBackward = function() { index--; gotoAndPlay(frames[index]); trace(frames[index]); } Any help, suggestions, thoughts, tips would be greatly appreciated. Many thanks in advance, Cheers, Micky _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com