Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/02/2005, 15:47
jcl
 
Fecha de Ingreso: enero-2002
Mensajes: 673
Antigüedad: 22 años, 3 meses
Puntos: 1
¿Alguien sabe cómo y con qué se puede probar este código de reloj?

Alguien por alli me indicó este código, diciendo que le gustó mucho. Pero debido a que no tengo experiencia en flash, deseo que alguien me ayude, e cuanto a saber cómo y con qué puedo probar ese código.

Por supuesto, si se trata de hacer estudios especiales sobre Flash, creo que es mejor dejarlo para otra oportunidad cuando haya más tiempo para ello.

================================================== =====
/* Hecho para flash MX por: Fernando Flórez
* basado en el mismo experimento pero hecho en dhtml
*/
clockHeight = 50;
clockWidth = 50;
clockFromMouseY=0;
clockFromMouseX=100;

d = ["domingo", "lunes", "martes", "miercoles", "jueves", "viernes"];
m = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio",
"agosto", "setiembre", "octubre", "noviembre", "diciembre"];
dia = new Date().getDate();
anio = new Date().getFullYear();
fechaHoy = " "+d[new Date().getDay()]+" "+dia+" "+m[new Date().getMonth()]+" "+anio;
d2 = fechaHoy.split("");
H = "...".split("");
M = "....".split("");
S = ".....".split("");
vel = 0.6;
tam = "1 2 3 4 5 6 7 8 9 10 11 12".split(" ");
split = 360/tam.length;
dsplit = 360/d2.length;
handHeight = clockHeight/4.5;
handWidth = clockWidth/4.5;
handY = -7;
handX = -2.5;
step = 0.06;
curStep = 0;
y = [];
x = [];
y2 = [];
x2 = [];
dy = [];
dx = [];
dy2 = [];
dx2 = [];
for(var i=0;i<tam.length;i++){
y.push(0);
x.push(0);
y2.push(0);
x2.push(0);
dy.push(0);
dx.push(0);
dy2.push(0);
dx2.push(0);
}
for(var i=0;i<d2.length;i++){
var tmp = createEmptyMovieClip("nsDate"+i, i);
with(tmp){
_x = _y = 0;
createTextField("texto", 0, 0, 0, null, null);
texto.autoSize = true;
texto.selectable = false;
texto.text = _parent.d2[i].toUpperCase();
}
}
for(var i=0;i<tam.length;i++){
var tmp = createEmptyMovieClip("nsFace"+i, (i+24));
with(tmp){
_x = _y = 0;
createTextField("texto", 0, 0, 0, null, null);
texto.autoSize = true;
texto.selectable = false;
texto.text = _parent.tam[i];
}
}
for(var i=0;i<S.length;i++){
var tmp = createEmptyMovieClip("nsSeconds"+i, (i+36));
with(tmp){
_x = _y = 0;
createTextField("texto", 0, 0, 0, null, null);
texto.autoSize = true;
texto.selectable = false;
texto.text = _parent.S[i];
}
}
for(var i=0;i<M.length;i++){
var tmp = createEmptyMovieClip("nsMinutes"+i, (i+41));
with(tmp){
_x = _y = 0;
createTextField("texto", 0, 0, 0, null, null);
texto.autoSize = true;
texto.selectable = false;
texto.text = _parent.M[i];
}
}
for(var i=0;i<H.length;i++){
var tmp = createEmptyMovieClip("nsHours"+i, (i+45));
with(tmp){
_x = _y = 0;
createTextField("texto", 0, 0, 0, null, null);
texto.autoSize = true;
texto.selectable = false;
texto.text = _parent.H[i];
}
}
function clockAndAssign(){
sec = -1.57 + Math.PI * new Date().getSeconds()/30;
min = -1.57 + Math.PI * new Date().getMinutes()/30;
hrs = -1.575 + Math.PI * new Date().getHours()/6+Math.PI*parseInt(new Date().getMinutes())/360;
for(var i=0;i<tam.length;i++){
this["nsFace"+i]._y = y[i] + clockHeight*Math.sin(-1.0471 + i*split*Math.PI/180);
this["nsFace"+i]._x = x[i] + clockWidth*Math.cos(-1.0471 + i*split*Math.PI/180);
}
for(var i=0;i<H.length;i++){
this["nsHours"+i]._y = y[i]+handY+(i*handHeight)*Math.sin(hrs);
this["nsHours"+i]._x = x[i]+handX+(i*handWidth)*Math.cos(hrs);
}
for(var i=0;i<M.length;i++){
this["nsMinutes"+i]._y = y[i]+handY+(i*handHeight)*Math.sin(min);
this["nsMinutes"+i]._x = x[i]+handX+(i*handWidth)*Math.cos(min);
}
for(var i=0;i<S.length;i++){
this["nsSeconds"+i]._y = y[i]+handY+(i*handHeight)*Math.sin(sec);
this["nsSeconds"+i]._x = x[i]+handX+(i*handWidth)*Math.cos(sec);
}
for(var i=0;i<d2.length;i++){
this["nsDate"+i]._y = dy[i] + clockHeight*1.5*Math.sin(curStep+i*dsplit*Math.PI/180);
this["nsDate"+i]._x = dx[i] + clockWidth*1.5*Math.cos(curStep+i*dsplit*Math.PI/180);
}
curStep -= step;
}
function delay(){
dy[0]= Math.round(dy2[0]+=((_ymouse+clockFromMouseY)-dy2[0])*vel);
dx[0]= Math.round(dx2[0]+=((_xmouse+clockFromMouseX)-dx2[0])*vel);
for (var i=1; i < d2.length; i++){
dy[i]= Math.round(dy2[i]+=(dy[i-1]-dy[i])*vel);
dx[i]= Math.round(dx2[i]+=(dx[i-1]-dx[i])*vel);
}
y[0]= Math.round(y2[0]+=((_ymouse+clockFromMouseY)-y2[0])*vel);
x[0]= Math.round(x2[0]+=((_xmouse+clockFromMouseX)-x2[0])*vel);
for (i=1; i < tam.length; i++){
y[i]= Math.round(y2[i]+=(y[i-1]-y2[i])*vel);
x[i]= Math.round(x2[i]+=(x[i-1]-x2[i])*vel);
}
clockAndAssign();
}
clockAndAssign();
delay();
setInterval(delay, 20);