|
Alarm clock
/*create two text field of dynamic nature and then wite this script*/
onClipEvent (enterFrame) {
currenttime=new Date();
zee = new Date();
datay = (zee.getDate());
currenthour=currenttime.getHours()-1;
if (currenthour>=13) {
currenthour=currenthour-12;
shift="pm"
} else {shift="am";
}
currentminutes=currenttime.getMinutes();
if (currentminutes<10) {
currentminutes="0"+currentminutes;
}
currentseconds=currenttime.getSeconds();
if (currentseconds<10) {
currentseconds="0"+currentseconds;
}
currentms=currenttime.getMilliseconds();
if (currentms>100) {
currentms=currentms/10;
}
currentday=currenttime.getDay();
if (currentday==0) {
currentday="sun"}
else if (currentday==1) {
currentday="mon"} else if (currentday==2) {
currentday="tues"} else if (currentday==3) {
currentday="wed"} else if (currentday==4) {
currentday="thur"} else if (currentday==5) {
currentday="fri"} else if (currentday==6) {
currentday="sat"
}
currentdate=currenttime.getMonth();
if ( currentdate==0 ) {
currentdate="jan"} else if (currentdate==1) {
currentdate="FEB"} else if (currentdate==2) {
currentdate="MARCH"} else if (currentdate==3) {
currentdate="APRIL"} else if (currentdate==4) {
currentdate="MAY" } else if (currentdate==5) {
currentdate="june" } else if ( currentdate==6 ) {
currentdate="july" } else if (currentdate==7) {
currentdate="aug" } else if (currentdate==8) {
currentdate="sep" } else if (currentdate==9) {
currentdate="oct" } else if (currentdate==10) {
currentdate="nov" } else if (currentdate==11) {
currentdate="dec"
}
currentyear=currenttime.getYear();
if (currentyear>100) {
currentyear="20"+"0"+(currentyear-100);
}
zeeshan=currenthour +":"+ currentminutes+":"+ currentseconds+":"+currentms+" "+shift;
if ((currenthour==this._root.hr)&&(currentminutes==this._root.min)){
this._root.gotoAndPlay(11);
}
khan=currentday+"/"+datay+"/"+currentdate+"/"+currentyear;
}Posted by: zeeshan khan | website http://www.ajkashmir.8k.com |
|
[Admin's Note] From 30 seconds of testing I believe this find a common factor for each number in the array and returns it... And yes, it does work.[/Admin's Note]
El algoritmo de Euclides, nos permite hallar el MCD de un vector de numeros: en un frame: //Comienzo Algoritmo de Euclides (son dos funciones) /*X A C A - - D E S I G N E R S Este algoritmo permite encontrar el maximo comun divisor de un conjunto de numeros de un vector.e-mail:xaca@inginfo.8k.com */
Math.Intercambio=function(x,y){
var a,b,k;
if(x<y)
{
b=x;
a=y;
k=a%b;
if(k==0)
return b;
else
return Math.Intercambio(y,k);
}
else
{
k=x%y;
if(k==0)
return y;
else
return Math.Intercambio(y,k);
}
} //fin de Intercambio
Math.EcuclidesMCD=function(vect){
for(j=1;j<vect.length;j++)
vect[j]=Math.Intercambio(vect[j-1],vect[j]);
return vect[vect.length-1];
}
//Fin Algoritmo de Euclides y para utilizarlo: creamos el vector de numero, que como minimo debe de tener 2 elementos
vecy=new Array(852,210,102,525,180);
// y aplicamos la funcion.
trace(Math.EcuclidesMCD(vecy));
//dedicado a CarolinaPosted by: xaca | website http:// |
/*paste this code in 1st frame .First of all place 7 pictures on stage then write this action script at first frame.you can take more or less pic. then change action script according to it */_root.a._alpha=100; _root.b._alpha=100; _root.c._alpha=100; _root.d._alpha=100; _root.e._alpha=100; _root.f._alpha=100; _root.g._alpha=100;
_root.a._alpha-=1;
if(_root.a._alpha<=0){
_root.b._alpha-=1;
}
if((_root.a._alpha<=0)&&(_root.b._alpha<=0)){
_root.c._alpha-=1;
}
if((_root.a._alpha<=0)&&(_root.b._alpha<=0)&&(_root.c._alpha<=0)){
_root.d._alpha-=1;
}
if((_root.a._alpha<=0)&&(_root.b._alpha<=0)&&(_root.c._alpha<=0)&&(_root.d._alpha<=0)){
_root.e._alpha-=1;
}
if((_root.a._alpha<=0)&&(_root.b._alpha<=0)&&(_root.c._alpha<=0)&&(_root.d._alpha<=0)&&(_root.e._alpha<=0)){
_root.f._alpha-=1;
}
if((_root.a._alpha<=0)&&(_root.b._alpha<=0)&&(_root.c._alpha<=0)&&(_root.d._alpha<=0)&&(_root.e._alpha<=0)&&(_root.f._alpha<=0)){
_root.g._alpha-=1;
stopAllSounds ();
gotoAndStop(1);
}gotoAndPlay(3); Posted by: zeeshan khan | website http://www.ajkashmir.8k.com |
_global.getDistance = function(x1,x2,y1,y2){ getDistance_delta_x = x1-x2; getDistance_delta_y = y1-y2; getDistance_distance = Math.sqrt((getDistance_delta_x*getDistance_delta_x)+(getDistance_delta_y*getDistance_delta_y)); return getDistance_distance; } //-- getDistance(x1,x2,y1,y2) // returns: Distance between x1,y1 and x2,y2 // description: Calculates the distance between two sets of X,Y. // x1: The X coordinate of position 1 // x2: The X coordinate of position 2 // y1: The Y coordinate of position 1 // y2: The Y coordinate of position 2 //Sample usage: distance = getDistance(1,50,3,75) trace(distance); Posted by: abeall | website http://abeall.com |
|
Firstly, define our points as two different movie clips. Let us make it like: AAA: Instance name for the first mc BBB: Instance name for the second mc Then, create the variables and define them: var a; var b; var distance; a = _root.AAA; b = _root.BBB; distance = Math.sqrt(((a._x - b._x) * (a._x - b._x)) + ((a._y - b._y) * (a._y - b._y))); Also, in order to get the result as an "integer", we can define the distance as in the following: distance = Math.round(Math.sqrt(((a._x - b._x) * (a._x - b._x)) + ((a._y - b._y) * (a._y - b._y))); Posted by: Mustafa Basgun | website http:// |

