alguien pedia el codigo para un reloj en flash...
esto no es exactamente lo que pedia (espero :) pero es
algo que tenia rodando por el disco duro (de lo primerito
que hice con Flash MX)
basicamente, es una conversion de un programa JavaScript
a ActionScript. Lamentablemente, no tengo a quien poner
en los creditos, puesto que el original no tenia creditos
en los comentarios, y el JS se perdio en el mar de los
tiempos... por si a alguien le sirve de pista, el fichero
se llamaba fundooo.js
el codigo, al final del mensaje (ALERTA: es bastante mas
farragoso de lo que tengo por costumbre publicar, porque
es una traduccion casi literal de JS a AS. Advertidos
estais :)
(ALERTA2: Se come el 100% de CPU. No esta optimizado para Flash)
[EMAIL PROTECTED] | www.bomberstudios.com | see less, think more
// Reloj-Calendario de Texto
// Traduccion de fundooo.js (autor desconocido) a fundooo.mx
// por [EMAIL PROTECTED]
// dimension and position stuff
myClockHeight=40;
myClockWidth=40;
myClockFromMouseY=0;
myClockFromMouseX=0;
myDsmall=new
Array("DOMINGO","LUNES","MARTES","MIERCOLES","JUEVES","VIERNES","SABADO");
myMsmall=new
Array("ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE");
myDate=new Date();
myDay=myDate.getDate();
myYear=myDate.getYear();
if (myYear < 2000){
myYear=myYear+1900;
}
TodaysDate=" "+myDsmall[myDate.getDay()]+" "+myDay+"
"+myMsmall[myDate.getMonth()]+" "+myYear;
myD=TodaysDate.split("");
myH="...";
myH=myH.split("");
myM="....";
myM=myM.split("");
myS=".....";
myS=myS.split("");
myFace="1 2 3 4 5 6 7 8 9 10 11 12";
myFont="Arial";
//Alter nothing below! Alignments will be lost!
mySize=3;
mySpeed=0.6;
myFace=myFace.split(" ");
myN=myFace.length;
myA = mySize*10;
myYmouse=0;
myXmouse=0;
myScrll=10;
mySplit=360/myN;
myDsplit=360/myD.length;
myHandHeight = myClockHeight/5.5;
myHandWidth = myClockWidth/5.5;
myHandY= -2;
myHandX= 8;
myScrll=0;
myStep=0.06;
myCurrStep=0;
myYsmall=new Array();
myXsmall=new Array();
myY=new Array();
myX=new Array();
for (var i=0; i < n; i++){
myYsmall[i]=0;
myXsmall[i]=0;
myY[i]=0;
myX[i]=0;
}
myDysmall=new Array();
myDxsmall=new Array();
myDY=new Array();
myDX=new Array();
for (var i=0; i < D.length; i++){
myDysmall[i]=0;
myDxsmall[i]=0;
myDY[i]=0;
myDX[i]=0;
}
myTextFormat = new TextFormat();
myTextFormat.size = 9;
myTextFormat.font = "Verdana";
myTextFormat.align = "center";
for (var i=0; i < myD.length; i++){
_root.createTextField("nsDate"+i,i,0,i*10,myA,myA);
_root["nsDate"+i].setNewTextFormat(myTextFormat);
_root["nsDate"+i].text = myD[i];
_root["nsDate"+i].selectable = false;
}
for ( var i=0; i < myN; i++){
_root.createTextField("nsFace"+i,i+100,20,i*10,myA,myA);
_root["nsFace"+i].setNewTextFormat(myTextFormat);
_root["nsFace"+i].text = myFace[i];
_root["nsFace"+i].selectable = false;
}
for (var i=0; i < myS.length; i++){
_root.createTextField("nsSeconds"+i,i+200,40,i*10,15,15);
_root["nsSeconds"+i].setNewTextFormat(myTextFormat);
_root["nsSeconds"+i].text = myS[i];
_root["nsSeconds"+i].selectable = false;
}
for (var i=0; i < myM.length; i++){
_root.createTextField("nsMinutes"+i,i+300,60,i*10,15,15);
_root["nsMinutes"+i].setNewTextFormat(myTextFormat);
_root["nsMinutes"+i].text = myM[i];
_root["nsMinutes"+i].selectable = false;
}
for (var i=0; i < myH.length; i++){
_root.createTextField("nsHours"+i,i+400,80,i*10,15,15);
_root["nsHours"+i].setNewTextFormat(myTextFormat);
_root["nsHours"+i].text = myH[i];
_root["nsHours"+i].selectable = false;
}
function myMouse(){
myYmouse = _root._ymouse + myClockFromMouseY;
myXmouse = _root._xmouse + myClockFromMouseX;
}
_root.onMouseMove = myMouse;
ClockAndAssign = function (){
var time = new Date ();
var secs = time.getSeconds();
var sec = -1.57 + Math.PI * secs/30;
var mins = time.getMinutes();
var minute = -1.57 + Math.PI * mins/30;
var hour = time.getHours();
var hours = -1.575 + Math.PI *
hour/6+Math.PI*parseInt(time.getMinutes())/360;
for (var i=0; i < myN; i++){
var F = _root["nsFace"+i];
F._y = myYsmall[i] + myClockHeight*Math.sin(-1.0471 +
i*mySplit*Math.PI/180)+myScrll;
F._x = myXsmall[i] + myClockWidth*Math.cos(-1.0471 +
i*mySplit*Math.PI/180);
}
for (var i=0; i < myH.length; i++){
var HL = _root["nsHours"+i];
HL._y = myYsmall[i] + myHandY + (i*myHandHeight)*Math.sin(hours) +
myScrll;
HL._x = myXsmall[i] + myHandX + (i*myHandWidth)*Math.cos(hours);
}
for (var i=0; i < myM.length; i++){
var ML=_root["nsMinutes"+i];
ML._y = myYsmall[i] + myHandY + (i*myHandHeight)*Math.sin(minute) +
myScrll;
ML._x = myXsmall[i] + myHandX + (i*myHandWidth)*Math.cos(minute);
}
for (var i=0; i < myS.length; i++){
var SL= _root["nsSeconds"+i];
SL._y = myYsmall[i] + myHandY + (i*myHandHeight)*Math.sin(sec) +
myScrll;
SL._x = myXsmall[i] + myHandX + (i*myHandWidth)*Math.cos(sec);
}
for (var i=0; i < myD.length; i++){
var DL= _root["nsDate"+i];
DL._y = myDysmall[i] +
myClockHeight*1.5*Math.sin(myCurrStep+i*myDsplit*Math.PI/180)+myScrll;
DL._x = myDxsmall[i] +
myClockWidth*1.5*Math.cos(myCurrStep+i*myDsplit*Math.PI/180);
}
myCurrStep-=myStep;
}
_root.onEnterFrame = function(){
ClockAndAssign();
Delay();
}
function Delay(){
myScrll = 0;
myDysmall[0] = Math.round(myDY[0]+=((myYmouse)-myDY[0])*mySpeed);
myDxsmall[0] = Math.round(myDX[0]+=((myXmouse)-myDX[0])*mySpeed);
for (var i=1; i < myD.length; i++){
myDysmall[i]=Math.round(myDY[i]+=(myDysmall[i-1]-myDY[i])*mySpeed);
myDxsmall[i]=Math.round(myDX[i]+=(myDxsmall[i-1]-myDX[i])*mySpeed);
}
myYsmall[0]=Math.round(myY[0]+=((myYmouse)-myY[0])*mySpeed);
myXsmall[0]=Math.round(myX[0]+=((myXmouse)-myX[0])*mySpeed);
for (var i=1; i < myN; i++){
myYsmall[i]=Math.round(myY[i]+=(myYsmall[i-1]-myY[i])*mySpeed);
myXsmall[i]=Math.round(myX[i]+=(myXsmall[i-1]-myX[i])*mySpeed);
}
}