------------------------------------------------------------------------------------------------------------------------
CODE AS2
https://www.youtube.com/watch?v=H7IvquSlPOA
http://itsystemid.blogspot.co.uk/search/label/aplikasi%20delphi?max-results=4
-----------------------------------------------------------------------------------------------------------------------
SOME TIME DUE TO FONT ERROR YOUR FUNCTION NOT WORK
SO YOU NEED TO SET FONT IN FLASH WHICH ALREADY USE YOUR COMPUTER
FAMILY: ARIAL
STYLE: REGULAR
-----------------------------------------------------------------------------------------------------------------------
Txt1.maxChars = 9;
Txt2.maxChars = 9;
var Num1:Number = Number(Txt1.text);
var Num2:Number = Number(Txt2.text);
Bn1.onPress=function(){
var Num1:Number = Number(Txt1.text)+ Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn2.onPress=function(){
var Num1:Number = Number(Txt1.text)- Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn3.onPress=function(){
var Num1:Number = Number(Txt1.text) / Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn4.onPress=function(){
var Num1:Number = Number(Txt1.text) * Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
ClearBtn.onPress=function(){
Txt1.text=""
Txt2.text=""
Txt3.text=""
}
------------------------------------------------------------------------------------------------------------------------
CODE AS3
-----------------------------------------------------------------------------------------------------------------------
Txt1.maxChars = 9;
Txt2.maxChars = 9;
var Num1:Number = Number(Txt1.text);
var Num2:Number = Number(Txt2.text);
Bn1.addEventListener(MouseEvent.CLICK,Fn1)
function Fn1(e:MouseEvent){
var Num1:Number = Number(Txt1.text)+ Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn2.addEventListener(MouseEvent.CLICK,Fn2)
function Fn2(e:MouseEvent){
var Num1:Number = Number(Txt1.text)- Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn3.addEventListener(MouseEvent.CLICK,Fn3)
function Fn3(e:MouseEvent){
var Num1:Number = Number(Txt1.text) / Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
Bn4.addEventListener(MouseEvent.CLICK,Fn4)
function Fn4(e:MouseEvent){
var Num1:Number = Number(Txt1.text) * Number(Txt2.text)
Txt3.text = "ANSWER:" + " " + String(Num1)
}
ClearBtn.addEventListener(MouseEvent.CLICK,CLEAR)
function CLEAR(e:MouseEvent){
Txt1.text=""
Txt2.text=""
Txt3.text=""
}
--------------------------------------------------------------------------------------------------------------------
FLASH CALCULATORS AS2 WITH TWO BOXES
---------------------------------------------------------------------------------------------------------------------
// OR USE THIS CODE SHOW ANSWER IN TEXT BOX 1//
Bn1.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Num3:Number = Num1 + Num2
Txt1.text = "ANSWER:" + " " + String(Num3)
}
---------------------------------------------------------------------------------------------------------------------
// OR USE THIS CODE SHOW ANSWER IN TEXT BOX 2//
Bn1.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Num3:Number = Num1 + Num2
Txt2.text = "ANSWER:" + " " + String(Num3)
}
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
FLASH CALCULATORS AS2 WITH TWO BOXES WITH VARIABLES
1) IN THIS METHOD WE DON'T USE TEXT BOX INSTANCE NAMES
2) IT WORKS WITH VARIABLE NAMES
3) WE TYPES ONE NUMBER IN inputNum VARIABLE BOX
4) IT SHOW ANSWER IN outputNum VARIABLE BOX
5) YOU CAN CHANGE outputNum = LINE WITH BELOW LINES
outputNum = inputNum * inputNum;
outputNum = 1 / inputNum;
---------------------------------------------------------------------------------------------------------------------
// AS2 CODE
//NEED DISPLAY VARIABLE NAMES IN TEXT FIELD
//NO NEED TEXT BOX INSTANCE NAME NAMES
// IT WORKS LIKE AS2 COUNTER
var inputNum:Number = 0;
var outputNum:Number = 0;
Bn1.onPress = function() {
outputNum = inputNum * 2;
}
// OR USE THIS CODE FOR SAME RESULT WITH TEXT BOX INSTANCE NAMES
// WE DON'T NEED TO WRITE VARIABLE NAME IN VARIABLE BOX
// AS2 CODE
//NO NEED DISPLAY VARIABLE NAMES IN TEXT FIELD
// NEED TEXT BOX INSTANCE NAME NAMES
Bn1.onPress=function(){
var inputNum:Number = Number(Txt1.text)
var inputNum:Number = Number(Txt1.text)
var outputNum:Number = inputNum * 2;
Txt2.text = String(outputNum)
}
------------------------------------------------------------------------------------------------------
OR USE THIS CODE IN AS3
---------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------- DISPLAY VARIABLE NAMES IN AS3 IT WORKS FINE BUT IT SHOW DUPLICATE VARIABLE ERROR CHANGE BUTTON LISTENER CODE --------------------------------------------------------------------------------------------------------------------------------------------- // AS3 CODE //NO NEED DISPLAY VARIABLE NAMES IN TEXT FIELD // NEED TEXT BOX INSTANCE NAME NAMES Bn1.addEventListener(MouseEvent.CLICK,Fn1) function Fn1(e:MouseEvent){ var inputNum:Number = Number(Txt1.text) var inputNum:Number = Number(Txt1.text) var outputNum:Number = inputNum * 2 Txt2.text = String(outputNum) } // OR USE THIS CODE WITHOUT DUPLICATE VARIABLE ERROR // JUST CHANGE VARIABLE NAME var inputNum2:Number = Number(Txt1.text) // AS3 CODE //NO NEED DISPLAY VARIABLE NAMES IN TEXT FIELD // NEED TEXT BOX INSTANCE NAME NAMES Bn1.addEventListener(MouseEvent.CLICK,Fn1) function Fn1(e:MouseEvent){ var inputNum:Number = Number(Txt1.text) var inputNum2:Number = Number(Txt1.text) var outputNum:Number = inputNum * 2 Txt2.text = String(outputNum) }
PERCENTAGE CALCULATOR CODE AS2
A STUDENT GOT 40 MARKS OUT OF 50 HOW MANY NUMBER GOT IN 100
40/50 * 100 = 80%
OR
WHAT IS 40 % PERCENT OF
40/100 * 50 = 20 %
-------------------------------------------------------------------------------------------------------------------
1) 40/50 * 100 = 80%
-------------------------------------------------------------------------------------------------------------------
Bn1.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Num3:Number = Num1 / Num2
Txt2.text = "ANSWER:" + " " + String(Num3)
Txt3.text = "PERCENTAGE:" + " " + String(Num3) * 100 + " %"
}
--------------------------------------------------------------------------------------------------------------
2) 40/100 * 50 = 20 %
--------------------------------------------------------------------------------------------------------------
Bn1.onPress=function(){
var Num1:Number = Number(Txt1.text)/ 100
var Num2:Number = Number(Txt2.text)
var Num3:Number = Num1 * Num2
Txt3.text = "PERCENTAGE:" + " " + String(Num3) + " %"
}
--------------------------------------------------------------------------------------------------------
PERCENTAGE CALCULATOR IN JAVA
http://www.onlineconversion.com/percentcalc.htm
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
INPUT CALCULATOR AS2 CODE
1) SET TEXT FONT ARIAL REGUALR
2) MAKE TWO INPUT BOXES
3) GIVE INSTANCE NAMES Txt1,Txt2
4)MAKE 4 BUTTONS WITH INSTANCE NAMES
PLUS,MINUS,MULTI,DIVIDE
--------------------------------------------------------------------------------------------------------------
PLUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 + Num2 ;
Txt2.text = "PLUS:"+ Total
}
MINUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 - Num2 ;
Txt2.text = "MINUS:"+ Total
}
MULTI.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 * Num2 ;
Txt2.text = "MULTI:"+ Total
}
DIVIDE.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 / Num2 ;
Txt2.text = "DIVIDE:"+ Total
}
--------------------------------------------------------------------------------------------------------
OR USE THIS CODE FOR SAME RESULT
-------------------------------------------------------------------------------------------------------
PLUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Number(Txt1.text) + Number(Txt2.text);
Txt2.text = "PLUS:"+ Total
}
MINUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Number(Txt1.text) - Number(Txt2.text);
Txt2.text = "MINUS:"+ Total
}
MULTI.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Number(Txt1.text) * Number(Txt2.text);
Txt2.text = "MULTI:"+ Total
}
DIVIDE.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Number(Txt1.text) / Number(Txt2.text);
Txt2.text = "DIVIDE:"+ Total
}
--------------------------------------------------------------------------------------------------------
SHOW ANSWERS IN TWO TEXT BOX WITH RETURN FUNCTION
--------------------------------------------------------------------------------------------------------
Txt1.text = 0;
Txt2.text = 0;
PLUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 + Num2 ;
Txt1.text = Total * 1
Txt2.text = Total * 1
}
MINUS.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 - Num2 ;
Txt1.text = Total * 1
Txt2.text = Total * 1
}
MULTI.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 * Num2 ;
Txt1.text = Total * 1
Txt2.text = Total * 1
}
DIVIDE.onPress=function(){
var Num1:Number = Number(Txt1.text)
var Num2:Number = Number(Txt2.text)
var Total:Number = Num1 / Num2 ;
Txt1.text = Total * 1
Txt2.text = Total * 1
}
EmoticonEmoticon