Scripting for Slide Viewer - A Problem
I am hacking up one of the movies posted here on Flashkit, some of you may have come across it, A handy little slide viewer from ValueAmerica.
Content Slider - Slides to Matrix Coordinates
I don't really script, so I'm guessing this is something REALLY simple and obvious, and hoping one of you may be able to point it out.
The movie comes with 100 slides built into a "Contents" MC - ungroup the Contents, edit, regroup, et voila!
Cool, except I don't have or or need 100 slides. I cut the ones I didn't need, leaving 30. PageTotal sets the number of slides in the script - I changed this to 30.
If you cycle forward through all the slides, 1, 2, 3...etc...up to 100, then press forward again, you go back to slide 1.
This still works - if you cycle through all 30 slides, you return to the 1st slide.
However, if you are on slide 1 and press back, it used to take you down to slide 100. Now, it still tries to take you to where slide 100 would have been (but of course it is deleted). So some condition has not been built into the back button it seems to dynamically update when PageTotal is changed - but I can't spot anything hard-coded to 100 slides. So I'm lost.
Here's the code (it's MX - it doesn't work if I publish it as Flash 8):
Code:
//
// SlideMenu funtion controls the speed of the movement to the next window
// Change the last number if you want to change the speed
function SlideMenu() {
this._x += (newX-this._x)/6;
this._y += (newY-this._y)/6;
}
// This next line calls the funtion named SlideMenu
WindowIN.Contents.onEnterFrame = SlideMenu;
newX = 0;
newY = 0;
//The next line is where you indicate the total number of display area(s)
PageTotal = 30;
//This is where we set our counter to 1
//The counter later limits the count to a maximum of the number set in PageTotal
CounterDisplay = 1;
//The following function is assigned to the Forward button
Forward.Forward.onPress = function() {
CounterNumber++;
XNumber++;
// limit input field to a maximum as indicated above in PageTotal
if (CounterNumber>PageTotal-1) {
CounterNumber = 0;
XNumber = 0;
YNumber = 0;
}
CounterDisplay = CounterNumber+1;
if (XNumber>9) {
XNumber = 0;
YNumber++;
}
newX = -XNumber*60;
newY = -YNumber*50;
};
//This is a similar function for the Back button except in reverse
Back.Back.onPress = function() {
CounterNumber--;
XNumber--;
if (CounterNumber<0) {
CounterNumber = PageTotal-1;
XNumber = 9;
YNumber = 9;
}
CounterDisplay = CounterNumber+1;
if (XNumber<0) {
XNumber = 9;
YNumber--;
}
newX = -XNumber*60;
newY = -YNumber*50;
};
Has to be something in the Back.Back segment, I just can't figure out what. Any and all help appreciated.
In related news, I am also trying to figure out a way to incite Forward.Forward.onPress = function() on a timed schedule. So kinda like a function - SetInterval - function setup, but that doesn't quite work here.
It needs to say every X seconds then Forward.Forward AND ALSO onPress, Forward.Forward.
Any help on this topic also much appreciated...
~d