Code.GeekInterview.com
 
Code Samples Flash
 

Addition of Two Numbers Using User Defined Class


Code ResourceAuthor: lavanyarani  

Difficulty Level: Intermediate

Published: 6th Jan 2010   Read: 4733 times  

Filed in: Flash
Add Comment


 

 

Sponsored Links


 

 

Addition of two numbers interactively.

 


Sample Code
  1. Step-1: Select the action script file while opening the flash.
  2. Step-2: Write the following code in the script pane.
  3.  
  4.              class Mathss
  5. {
  6.                 var a:Number;
  7.                 var b:Number;
  8.                 var c:Number;
  9.                 public function addition(m,n):Number
  10.                 {
  11.                         a=m;
  12.                         b=n;
  13.                         c=a+b;
  14.                         return c;
  15.                 }
  16. }
  17. Step-3: Save the above file as Mathss.as  
  18. Step-4: Select the flash document while opening the flash.
  19. Step-5: Create 3 input boxes(texts) and name them as n1, n2, r1.
  20. Step-6: Create a button with the text on it as “ADDon it.
  21. Step-7: Select the buttonaddand open the script pane and write the
  22.              following code.
  23.              on (release)      
  24.         {
  25.                 var ob:Mathss=new Mathss();
  26.                 r1.text=ob.addition(Number(n1.text),Number(n2.text));
  27. }
  28. Note: 1) Flash document should be saved with the same name      
  29.             “Mathss.fla
  30.           2) Class name and action script file name should be same.
  31.          3) Both action script (.as) file and flash document (.fla) should be  
  32.                in the same folder.
  33.  
  34.  
Copyright GeekInterview.com


Next Article: Import Audio File


 

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. lavanyarani35496

Active Coders

# Coder NameCodes
1. lavanyarani13

Refined Tags