BASIC AS2 CALCULATOR actionscript                              as2
stop();

vysledok_txt.setStyle("textAlign", "right");
vysledok_txt.enabled = false;
border_txt.enabled = false;
var n:String = "";
var temp:Number;
var total:Number;
var operacia:String = "";

num1_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "1";
		vysledok_txt.text = n;
	}
}
num2_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "2";
		vysledok_txt.text = n;
	}
}
num3_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "3";
		vysledok_txt.text = n;
	}
}
num4_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "4";
		vysledok_txt.text = n;
	}
}
num5_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "5";
		vysledok_txt.text = n;
	}
}
num6_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "6";
		vysledok_txt.text = n;
	}
}
num7_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "7";
		vysledok_txt.text = n;
	}
}
num8_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "8";
		vysledok_txt.text = n;
	}
}
num9_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "9";
		vysledok_txt.text = n;
	}
}
num0_btn.onRelease = function(){
	if(length(n) < 20){
		n = n + "0";
		vysledok_txt.text = n;
	}
}
dot_btn.onRelease = function(){
	var symbolPos:Number = vysledok_txt.text.indexOf(".");
	if(length(n) < 20 && symbolPos == -1){
		n = n + ".";
		vysledok_txt.text = n;
	}
}
clear_btn.onRelease = function(){
	n = "";
	vysledok_txt.text = "";
}
equals_btn.onRelease = function(){
	if(operacia == "+"){
		n = "";
		total = Number(vysledok_txt.text);
		vysledok_txt.text = temp + total;
		operacia ="";
	}else if(operacia == "-"){
		n = "";
		total = Number(vysledok_txt.text);
		vysledok_txt.text = temp - total;
	}else if(operacia == "*"){
		n = "";
		total = Number(vysledok_txt.text);
		vysledok_txt.text = temp * total;
	}else if(operacia == "/"){
		n = "";
		total = Number(vysledok_txt.text);
		vysledok_txt.text = temp / total;
	}else if(operacia == "^"){
		n = "";
		total = Number(vysledok_txt.text);
		vysledok_txt.text = Math.pow(temp,total);
	}
}
plus_btn.onRelease = function(){
	temp = Number(vysledok_txt.text);
	vysledok_txt.text = "";
	n = "";
	operacia = "+";
}
minus_btn.onRelease = function(){
	temp = Number(vysledok_txt.text);
	vysledok_txt.text = "";
	n = "";
	operacia = "-";
}
multiple_btn.onRelease = function(){
	temp = Number(vysledok_txt.text);
	vysledok_txt.text = "";
	n = "";
	operacia = "*";
}
divide_btn.onRelease = function(){
	temp = Number(vysledok_txt.text);
	vysledok_txt.text = "";
	n = "";
	operacia = "/";
}
sin_btn.onRelease = function(){
	angDeg = Number(vysledok_txt.text); // v stupnoch
	angRad = angDeg * Math.PI / 180 ; //prevod na radiany
	vysledok_txt.text = Math.sin(angRad);
	n = "";
}
cos_btn.onRelease = function(){
	angDeg = Number(vysledok_txt.text); // v stupnoch
	angRad = angDeg * Math.PI / 180 ; //prevod na radiany
	vysledok_txt.text = Math.cos(angRad);
	n = "";
}
tan_btn.onRelease = function(){
	angDeg = Number(vysledok_txt.text); // v stupnoch
	angRad = angDeg * Math.PI / 180 ; //prevod na radiany
	vysledok_txt.text = Math.tan(angRad);
	n = "";
}
pow_btn.onRelease = function(){
	temp = Number(vysledok_txt.text);
	vysledok_txt.text = "";
	n = "";
	operacia = "^";
}
ln_btn.onRelease = function(){
	vysledok_txt.text = Math.log(Number(vysledok_txt.text));
	n = "";
}
exp_btn.onRelease = function(){
	vysledok_txt.text = Math.exp(Number(vysledok_txt.text));
	n = "";
}
sqrt_btn.onRelease = function(){
	vysledok_txt.text = Math.sqrt(Number(vysledok_txt.text));
	n = "";
}


BACK TO PREVIOUS PAGE