Code.GeekInterview.com
 
Code Samples Flash
 

Simple Mathematic Operations (Round, Ceil, Floor, Square Root)


Code ResourceAuthor: lavanyarani  

Difficulty Level: Intermediate

Published: 6th Jan 2010   Read: 3296 times  

Filed in: Flash
Add Comment


 

 

Sponsored Links


 

 

This program shows how to perform simple Mathematic Operations (Round, Ceil, Floor, Square Root)

 


Sample Code
  1. Step-1: Create 4 input boxes (text) and give the names to them as n, n1,
  2.              n2, r1
  3. Step-2: Create 7 buttons with the text on them as “round”, “ceil”, “log”
  4.              “square root”, “min”, “max”.
  5. Step-3: Select the button (round) and open the script and write the
  6.              following  code  
  7.                 on (release)
  8.  {
  9.                           r1.text=Math.round(Number(n1.text));
  10.                     }
  11.  
  12. Step-4: Select the button (ceil) and open the script and write the
  13.              following  code  
  14.                 on (release)
  15.  {
  16.                           r1.text=Math.ceil(Number(n1.text));
  17.                     }
  18. Step-5: Select the button (floor) and open the script and write the
  19.              following  code  
  20.                 on (release)
  21.  {
  22.                           r1.text=Math.floor(Number(n1.text));
  23.                     }
  24. Step-6: Select the button (log) and open the script and write the
  25.              following  code  
  26.                 on (release)
  27.  {
  28.                           r1.text=Math.log(Number(n1.text));
  29.                     }
  30.  
  31. Step-7: Select the button (square root) and open the script and write the
  32.              following  code  
  33.                 on (release)
  34.  {
  35.                           r1.text=Math.sqrt(Number(n1.text));
  36.                     }
  37.  
  38. Step-8: Select the button (min) and open the script pane and write the following code
  39.    on (release)
  40.  {
  41.         r1.text=Math.min(Number(s1.text),Number(s2.text));
  42. }
  43. Step-9: Select the button (max) and open the script pane and write the following code
  44.    on (release)
  45.  {
  46.         r1.text=Math.max(Number(s1.text),Number(s2.text));
  47. }
  48.  
  49. Step-10: press ctrl+enter to test the movie give appropriate input and click the button (any) to perform mathematic operation the result will be printed on the “r1” field
  50.  
  51.  
Copyright GeekInterview.com


Next Article: Simple Mathematic Operations (Add, Sub, Mul, Div, Mod)


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. lavanyarani35504

Active Coders

# Coder NameCodes
1. lavanyarani13

Refined Tags