----------------------------------------------------------------------------------------------------
CODES:
----------------------------------------------------------------------------------------------------
var Num1:Number;
var Num2:Number;
trace(Num1+Num2);
//Mean undefined numeric value.
//Literally it means "Not A Number"
//Output = NaN
var Num1:Number = 1;
var Num2:Number = 2;
trace(Num1+Num2);
//Output = 3
var Num1:Number = 1;
var Num2:Number = 2;
var Total:Number;
Total = Num1 + Num2
trace(Total);
//Output = 3
----------------------------------------------------------------------------------------------------
CODES WITH BUTTON
----------------------------------------------------------------------------------------------------
//Under Num1 BUTTON CODE
on(press){
var Num1:Number = 1;
trace(Num1);
TraceTotal();
}
//Under Num2 BUTTON CODE
on(press){
var Num2:Number = 2;
trace(Num2);
TraceTotal();
}
//Main Time Frame No: 1 Code
function TraceTotal(){
var Total:Number;
Total = Num1 + Num2
trace(Total);
}
// When Press 1 And 2 Button Output:
1
NaN
2
3
// When Press 2 And 1 Button Output:
2
NaN
1
3
----------------------------------------------------------------------------------------------------
CODES WITH PLUS + BUTTON
----------------------------------------------------------------------------------------------------
//Under Num1 BUTTON CODE
on(press){
var Num1:Number = 1;
trace(Num1);
TraceTotal();
}
//Under Plus BUTTON CODE
on(press){
var Plus :String = "+"
trace(Plus);
}
//Under Num2 BUTTON CODE
on(press){
var Num2:Number = 2;
trace(Num2);
TraceTotal();
}
----------------------------------------------------------------------------------------------------
CODES WITH PLUS & TOTAL BUTTONS
----------------------------------------------------------------------------------------------------
//Under Num1 BUTTON CODE
on(press){
var Num1:Number = 1;
trace(Num1);
}
//Under Num2 BUTTON CODE
on(press){
var Num2:Number = 2;
trace(Num2);
}
//Under Plus BUTTON CODE
on(press){
var Plus :String = "+"
trace(Plus);
}
//Under Total BUTTON CODE
on(press){
function TraceTotal(){
var Total:Number;
if(Plus =="+"){
Total = Num1 + Num2
trace(Total);
}
}
TraceTotal();
}
// When Press 1,2,Total Buttons A Output:
1
2
3
// When Press 2,1,Total Buttons A Output:
2
1
3
----------------------------------------------------------------------------------------------------
CODES WITH PLUS MINUS & TOTAL BUTTONS
----------------------------------------------------------------------------------------------------
//Under Num1 BUTTON CODECODES WITH PLUS MINUS & TOTAL BUTTONS
----------------------------------------------------------------------------------------------------
on(press){
var Num1:Number = 1;
trace(Num1);
}
//Under Num2 BUTTON CODE
on(press){
var Num2:Number = 2;
trace(Num2);
}
//Under Plus BUTTON CODE
on(press){
var Plus :String = "+"
trace(Plus);
}
//Under Minus BUTTON CODE
on(press){
var Minus :String = "-"
trace(Minus);
}
//Under Total BUTTON CODE
on(press){
function TraceTotal(){
var Total:Number;
if(Plus =="+"){
Total = Num1 + Num2
trace(Total);
}
if(Minus =="-"){
Total = Num1 - Num2
trace(Total);
}
}
TraceTotal();
}
EmoticonEmoticon