Mil gracias! todo funciona perfectamente ahora!

Un saludo!
David

----- Original Message -----
From: "Xavi Beumala" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 8:12 PM
Subject: RE: [ASNativos] problema con un bucle


Hola,
El problema creo que no queda solucionado. Si pruebas con otro texto de
longitud distinta seguramente petar� y te har� el bucle otra vez.

El problema est� en las aproximaciones que haces con el Math.floor
Im�ginate una cadena de 41 caracteres. Al dividirlo por rapidez te
queda: 41/10 = 4.1 Si aplicas el floor te queda 4. Para esto har� que te
muestre los caracteres de 4 en 4. En la d�cima interacci�n habr�s
colocado 40. Esto quiere decir que en la siguiente interacci�n se
cumplir� el if (41>40) y colocaras 4 caracteres m�s, tendr�as 44 pero
s�lo puedes tener 41. Entonces lo que te hace es 44 modulo(41) que te da
3. En la siguiente interacci�n es cuando se repite el bucle, ya que en
vez de haberse quedado en 41, ha pasado a ser 3. En fin, un poco
rallante pero es lo que hay... ;-)

La soluci�n es quitarle el Math.floor y as� te ahorras lo de las
aproximaciones y todas las historias con �ndices negativos que tambi�n
aparecen :-S

Saludos a todos
Xavi Beumala
http://www.code4net.com

> -----Mensaje original-----
> De: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] En nombre de alexframes
> Enviado el: martes, 13 de enero de 2004 18:42
> Para: [EMAIL PROTECTED]
> Asunto: RE: [ASNativos] problema con un bucle
>
>
> A mi me funciona bien as�
>
> contenido.text="";
> f1()
> function f1(){
> texto="Lorem Ipsum is" ;
> i=0;
> rapidez=10;
> _root.onEnterFrame=function(){
> if (texto.length > contenido.length )
> {
> i++;
> contenido.text = texto.substr(texto.length - (i *
> Math.floor(texto.length / rapidez)),texto.length);
> }
> else {
> delete _root.onEnterFrame;
> }
> }
> }
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Marc el XrV
> Sent: martes, 13 de enero de 2004 18:08
> To: [EMAIL PROTECTED]
> Subject: Re: [ASNativos] problema con un bucle
>
> yo me lo he estado mirando un rato y no consigo entender pq falla,
> seguramente sea algo del algoritmo que usas...
>
> :P
>
>
> ---------- Original Message -----------
> From: "David de la Puente" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tue, 13 Jan 2004 16:12:27 +0100
> Subject: [ASNativos]  problema con un bucle
>
> > Hola a todos! a ver si alguno puede resolverme este problemilla.
> >
> > Tengo un campo de texto en el que meto el un texto y quiero q
> > mediante este script cargue el texto con este efecto. El problema
> > est� en que me hace el bucle 2 veces y quiero que lo haga solo una
> > vez, pero no s� por qu� lo hace, alguna idea?
> >
> > Gracias a todos!
> > Un saludo
> > David
> >
> > <code>
> > contenido="";
> > function f1(){
> >  texto="";
> >  contenido="";
> >  texto="Lorem Ipsum is simply dummy text of the printing and
> > typesetting industry. Lorem Ipsum has been the industry's standard
> > dummy text ever since the 1500s, when an unknown printer took a
> > galley of type and scrambled it to make a type specimen
> book. It has
> > survived not only five centuries, but also the leap into electronic
> > typesetting, remaining essentially unchanged. It was popularised in
> > the 1960s with the release of Letraset sheets containing
> Lorem Ipsum
> > passages, and more recently with desktop publishing software like
> > Aldus PageMaker including versions of Lorem Ipsum."; i=0;
> > rapidez=10;  contenido="";  _root.onEnterFrame=function(){  if
> > (texto.length > contenido.length ){    i++;    contenido =
> > texto.substr(texto.length - (i * Math.floor(texto.length /
> rapidez)),
> >  texto.length);     } else {    delete _root.onEnterFrame;   }// if
> > }// enterFrame }// function <!------------------------------- Lista
> ASNativos:
> > subscripciones/desubscripciones http://www.sidedev.net/asnativos
> > -------------------------------->
> ------- End of Original Message -------
>
> <!-------------------------------
> Lista ASNativos:
> subscripciones/desubscripciones http://www.sidedev.net/asnativos
> -------------------------------->
>
> <!-------------------------------
> Lista ASNativos:
> subscripciones/desubscripciones http://www.sidedev.net/asnativos
> -------------------------------->
>

<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->



<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->

Responder a