Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/02/2007, 13:18
juliopez
 
Fecha de Ingreso: enero-2007
Ubicación: vigo
Mensajes: 30
Antigüedad: 17 años, 11 meses
Puntos: 0
Re: javascript en firefox o safari no se ve

Imagen de "humo que sale del ratón, a 20 px de él, después de varios segundos" (el ratón sería una imagen de un cigarro, por ejemplo)
la página donde estoy probando el efecto es
eldescanso.es/humo/fuego.htm
(no tengo permisos para poner aquí enlaces)

<SCRIPT LANGUAGE="JavaScript">

ImageE = new Image();
ImageE.src = "es.gif";
Amount = 60;
Ymouse = 0;
Xmouse = 0;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nssize = new Array();
ns = (document.layers)?1:0;
(document.layers)?window.captureEvents(Event.mouse move):2;
function Mouse(evnt) {
Ymouse=(document.layers)?evnt.pageY-1:event.y-1;
Xmouse=(document.layers)?evnt.pageX-1:event.x-1;
}
(document.layers)?window.onMouseMove=Mouse:documen t.onmousemove=Mouse;
for (i = 0; i < Amount; i++) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random()*0.5+1;
Cstep[i] = 0;
Step[i] = Math.random()*0.1+0.05;
grow[i] = 100;
nssize[i] = Math.random()*600+15;
rate[i] = Math.random()*0+0.1;
}
if (ns) {
for (i = 0; i < Amount; i++) {
document.write("<layer><img src="+ImageE.src+" width="+nssize[i]+" height="+nssize[i]+"></layer>");
}
}
else {
document.write('<div style="position:absolute;top:-20px;left:-20px"><div style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="es" src="'+ImageE.src+'" style="position:absolute;top:-20px;left:-20px;filter:alpha(opacity=50)">');
}
document.write('</div>');
}
function Mouseesmo() {
var hscrll = (document.layers)?window.pageYOffset:document.body .scrollTop;
var wscrll = (document.layers)?window.pageXOffset:document.body .scrollLeft;
for (i = 0; i < Amount; i++){
sy = Speed[i] * Math.sin(370 * Math.PI / 40);
sx = Speed[i] * Math.cos(270 * Math.PI / 60);
Ypos[i] += sy;
Xpos[i] += sx;
if (Ypos[i] < -40) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random() * 6 + 4;
grow[i] = 20;
nssize[i] = Math.random() * 15 + 5;
}
if (ns) {
document.layers['sn'+i].left = Xpos[i] + wscrll;
document.layers['sn'+i].top = Ypos[i] + hscrll;
}
else {
es[i].style.pixelLeft = Xpos[i] + wscrll;
es[i].style.pixelTop = Ypos[i] + hscrll;
es[i].style.width = grow[i];
es[i].style.height = grow[i];
}
grow[i] += rate[i];
Cstep[i] += Step[i];
if (grow[i] > 200) grow[i] = 201;
}
setTimeout('Mouseesmo()', 0);
}
Mouseesmo();
// End -->
</script>