PDA

View Full Version : why are the spaces so big


brass fish
10-20-2002, 09:36 PM
hey, im made a script that makes text moves back and forth in the status bar. and i thought it was kinda bulka so i remade it.
this is what it should look like in the status

blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah
blah blah

and it keeps going like that. (each line is what the status looks like after .1 seconds). the first script did it fine. but when i remade it the spaces where huge.heres the code

var s='';
var spaces=new Array();
var p=0;
var fast=100;
var text;
function start(t,maxLength,item)
{
text=t;
textL=text.length;
if(textL>=maxLength)return false;
numospace=maxLength-textL;
for(var i=0;i<numospace;i++)
{
for(var j=0;j<=i;j++)
{
s=s+item;
}
spaces[i]=s;
}
right();
}
function right()
{
status=spaces[p]+text;
if(p<textL)p++;
else if(p==textL){left();return false;}
setTimeout('right();',fast);
}
function left()
{
status=spaces[p]+text;
if(p==0){right();return false;}
else p--;
setTimeout('left();',fast);
}

thanks :thumbsup:

fixed sum things

<html>
<head>
<script language="Javascript">
<!--
var spaces=new Array();
var p=0;
var fast=100;
var text;
function start(t,maxLength,item)
{
var s='';
text=t;
textL=text.length;
if(textL>=maxLength)return false;
numospace=maxLength-textL;
for(var i=0;i<numospace;i++)
{
for(var j=0;j<i;j++)
{
s+=item;
}
spaces[i]=s;
}
right();
}
function right()
{
status=spaces[p]+text;
if(p<numospace)p++;
else if(p==numospace){p--;left();return false;}
setTimeout('right();',fast);
}

function left()
{
status=spaces[p]+text;
if(!p){p++;right();return false;}
p--;
setTimeout('left();',fast);
}
start('example example example example example example example, Ooh, bouncy!',100,' ');
//-->
</script>
</head>
<body>

</body>
</html>

but i still cant fix the spaces thing, why are they so big!! oh, theres a pattern in the length of the spaces :

array # length of spaces
~~~~~~ ~~
spaces[0]= 0 0+1= 1
spaces[1]= 1 1+2= 3
spaces[2]= 3 3+3= 6
spaces[3]= 6 6+4=10
spaces[4]= 10 10+5=15
spaces[5]= 15 15+6=21
spaces[6]= 21 21+7=28
spaces[7]= 28 28+8=36.....

brass fish
10-21-2002, 10:32 PM
oh, heres an example of what the script should do(it uses the old script)
http://webjunk.coolfreepage.com/javascript/script2/index.html
and heres a link 2 the script im working on
http://webjunk.coolfreepage.com/javascript/script2/example.html

brass fish
10-22-2002, 11:11 PM
nevermind.... fixed it , 4got 2 reset s to '' after it assigned the space 2 the array:D

for(var i=0;i<numospace;i++)
{
for(var j=0;j<i;j++)
{
s+=item;
}
spaces[i]=s;
s='';
}