Code.GeekInterview.com
 
Code Samples Flash
 

Sorting and Reversing an Array


Code ResourceAuthor: lavanyarani  

Difficulty Level: Intermediate

Published: 10th Nov 2009   Read: 1651 times  

Filed in: Flash
Add Comment


 

 

Sponsored Links


 

 
This code helps to sorting and reversing an array
 


Sample Code
  1.  
  2. Step-1: Create 4 input texts(boxes) and give them names n1, n2, n3, n4  
  3.              respectively in the properties panel.
  4.  
  5. Step-2: Create 3 buttons with the test on them as “sort” ,”reverse”,
  6.              “sort and reverse”.
  7. Step-3: Create another 4 input texts(boxes) and give each of them names    
  8.              like r1, r2, r3, r4 respectively.
  9. Step-4: Select the “sortbutton and write the following code in the script      
  10.              pane
  11.               on (release)
  12.     {
  13.                        a=[t1.text,t2.text,t3.text,t4.text];
  14.                        a.sort();
  15.                        r1.text=a[0];
  16.                        r2.text=a[1];
  17.                        r3.text=a[2];
  18.                        r4.text=a[3];
  19.              }
  20. Step-5: Select the “reversebutton and open the action panel and write  
  21.              the following code in the script pane.
  22.  
  23.  
  24. on (release)
  25. {
  26. a=[t1.text,t2.text,t3.text,t4.text];
  27. a.reverse();
  28. r1.text=a[0];
  29. r2.text=a[1];
  30. r3.text=a[2];
  31. r4.text=a[3];
  32. }
  33. Step-6: Select the “reverse and sort buttonand open the action panel and            
  34.              write the following code in the script pane.
  35.  
  36. on (release)
  37. {
  38. a=[t1.text,t2.text,t3.text,t4.text];
  39. a.sort();
  40. a.reverse();
  41. r1.text=a[0];
  42. r2.text=a[1];
  43. r3.text=a[2];
  44. r4.text=a[3];
  45. }
  46. Step-7: press ctrl+enter  and enter any 4 names in 4 input boxes and select  
  47.              any one button then the appropriate action will be performed
  48.  
Copyright GeekInterview.com


Next Article: Detect Operating System


 

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

Active Coders

# Coder NameCodes
1. lavanyarani13

Refined Tags