Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/09/2009, 12:30
ZequeZ
 
Fecha de Ingreso: mayo-2008
Ubicación: En la guarida del mal, tratando de conquistar el mundo
Mensajes: 174
Antigüedad: 16 años
Puntos: 2
De acuerdo Respuesta: [Me trabé -.-] ¿Como paso un objeto con setInterval? :S

Hago una neuva respuesta porque lo solucioné =D
Despues de leer un tutorial muy completo sobre setInterval y setTimeout, entendí porque no me andaba xD.

Aca está la solución: (Eso no quiere decir que el script ande como debería eh? xD)

Código PHP:
<html>
    <
head>
        <
title>Prueba JS</title>
        <
script language="JavaScript">
            function 
move(objxa)
            {    
                
dist=parseInt(obj.style.left) - x;
                
sumat=sum(a);
                
window.a=a;
                
window.inter=setInterval("move2(document.getElementById('"+obj.id+"'), "+dist+", "+sumat+")"1000);
                
            }

            function 
move2(obj,dist,sumat)
            {
                
alert(obj.id);
                if(
dist<0)
                    
obj.style.left=parseInt(obj.style.left)+(dist/sumat)*window.a+"px";
                else
                    
obj.style.left=parseInt(obj.style.left)-(dist/sumat)*window.a+"px";
                
                
window.a--;
                if(
a<0)
                    
clearInterval(window.inter);
            }

            function 
sum(num)
            {
                var 
result=0;
                for(
i=1;i<=num;i++) result+=i;
                return 
result;
            }
        
</script>
    </head>

    <body style="margin:0px;padding:0px;">
        <div id="lol" style="width:100px;height:100px;position:absolute;left:10px;background-color:#000;" onMouseOver="move(this, 800, 100)"></div>
    </body>
</html>