PDA

View Full Version : marquee editing


tommeh
01-31-2005, 03:15 PM
ok what im trying to do is:
have a marquee that scrolls some links to songs, when you click on one image, it will speed up the speed of the marquee by changing the scrollAmount and scrollDelay properties, and clicking another image will decrease the speed.

the problem i am having is that my function only works once. So, i can speed it up once, but i cant make it go faster, or slower from that point.

help would be appreciated

function marqueeFaster ()
{
if (!p)
{
var p = 1;
}
else
{
p++;
}
alert(p);
if(p<=-5)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 50;
}
if(p==-4)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 25;
}
if(p==-3)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 10;
}
if(p==-2)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 4;
}
if(p==-1)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 2;
}
if(p==0)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 1;
}
if(p==1)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 200;
}
if(p==2)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 100;
}
if(p==3)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 50;
}
if(p==4)
{
song_marquee.scrollAmount = 4;
song_marquee.scrollDelay = 200;
}
if(p>=5)
{
song_marquee.scrollAmount = 4;
song_marquee.scrollDelay = 100;
}
}
function marqueeSlower ()
{
if (!p)
{
var p = -1;
}
else
{
p--;
}
alert(p);
if(p<=-5)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 50;
}
if(p==-4)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 25;
}
if(p==-3)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 10;
}
if(p==-2)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 4;
}
if(p==-1)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 2;
}
if(p==0)
{
song_marquee.scrollAmount = 1;
song_marquee.scrollDelay = 1;
}
if(p==1)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 200;
}
if(p==2)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 100;
}
if(p==3)
{
song_marquee.scrollAmount = 2;
song_marquee.scrollDelay = 50;
}
if(p==4)
{
song_marquee.scrollAmount = 4;
song_marquee.scrollDelay = 200;
}
if(p>=5)
{
song_marquee.scrollAmount = 4;
song_marquee.scrollDelay = 100;
}
}

umm pretty much the variable p is the speed counter level. 5 is fastest, -5 is slowest.
also, im relatively new to js so any tips on how to condense the script and make it easier to change would be helpful too i guess

btw the alert()'s are in there just for me to see if the counter is changing at all; it won't be in there in the 'final version'