Section 1
//MainTimeline (nave_fla.MainTimeline)
package nave_fla {
import flash.display.*;
import flash.text.*;
public dynamic class MainTimeline extends MovieClip {
public var hipotenusa:TextField;
public var lineaX;
public var navey:TextField;
public var ratax:TextField;
public var cateto:TextField;
public var navex:TextField;
public var ratay:TextField;
public var catop:Number;
public var mopet:Date;
public var lineaY;
public var catad:Number;
public var borderColor:uint;
public var borderSize:uint;
public var zona:Number;
public var nave:MovieClip;
public var angulo:TextField;
public var hipo:Number;
public var nave2:MovieClip;
public var angu;
public var linea2:Shape;
public var linea:Shape;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
mopet = new Date();
nave.rotation = ((mopet.getSeconds() * 60) + (mopet.getMilliseconds() * 0.06));
ratax.text = ("X = " + stage.mouseX);
ratay.text = ("Y = " + stage.mouseY);
navex.text = ("Nave x = " + nave2.x);
navey.text = ("Nave y = " + nave2.y);
catop = (stage.mouseY - nave2.y);
catad = (stage.mouseX - nave2.x);
hipo = Math.sqrt((Math.pow(catop, 2) + Math.pow(catad, 2)));
angu = ((Math.asin((catop / hipo)) * 180) / Math.PI);
zona = 0;
if (catop >= 0){
zona = 1;
} else {
if (catop < 0){
zona = 0;
};
};
if (catad < 0){
switch (zona){
case 1:
angu = (180 - angu);
break;
case 0:
angu = (-180 - angu);
break;
};
};
nave2.rotation = (angu + 90);
cateto.text = ("Cat OP = " + catop);
hipotenusa.text = ("Cat AD = " + catad);
borderColor = 0xFF00;
borderSize = 0;
lineaX = (Math.sin((((-1 * (nave.rotation + 180)) * Math.PI) / 180)) * 400);
lineaY = (Math.cos((((-1 * (nave.rotation + 180)) * Math.PI) / 180)) * 400);
angulo.text = ("Angulo Nave = " + nave.rotation);
linea = new Shape();
linea.graphics.lineStyle(borderSize, borderColor);
linea.graphics.moveTo(nave.x, nave.y);
linea.graphics.lineTo((lineaX + nave.x), (lineaY + nave.y));
addChild(linea);
linea2 = new Shape();
linea2.graphics.lineStyle(borderSize, borderColor);
linea2.graphics.moveTo(nave2.x, nave2.y);
linea2.graphics.lineTo(stage.mouseX, stage.mouseY);
addChild(linea2);
}
function frame2(){
removeChild(linea);
removeChild(linea2);
gotoAndPlay(1);
}
}
}//package nave_fla