PDA

View Full Version : horizontal scroller


munklemoose
02-27-2007, 05:12 PM
Hi, i have a horizontal scroller (im sure you've guessed!) in flash 6, it works but i want to use it within flash 8. I keep getting NaN in the counter. I think its to do with declaring CounterNumber. Anyone know of a quick fix? heres the code:

WindowIN._alpha = 0;
function SlideMenu() {
this._x += (newX-this._x)/5;
}
// This next line calls the funtion named SlideMenu
WindowIN.Contents.onEnterFrame = SlideMenu;
newX = 0;
//The next line is where you indicate the total number of display area(s)
PageTotal = 4;
//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;
}
CounterDisplay = CounterNumber+1;
if (XNumber>4) {
XNumber = 0;
}
newX = -XNumber*48;
};
//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 = 3;
}
CounterDisplay = CounterNumber+1;
if (XNumber<0) {
XNumber = 4;
}
newX = -XNumber*48;
};
stop();

zhatka
02-27-2007, 08:45 PM
You may want to make a few modifications to declare and strictly type your variables. Whil I am not sure if this will fix your problem, it should throw an error when you try to assign a non-number to a variable stricly typed as number.

example:

Counterdisplay = 1

becomes

var counterDisplay:Number = 1;

By assigning the datatype, when you debug in the IDE, you will get an error if any other datatype besides number attempts to get assigned.

Cheers,

z

munklemoose
03-01-2007, 11:02 AM
tried that but I still cant get it to work

:confused: