Step-1: Create 4 input texts(boxes) and give them names n1, n2, n3, n4
respectively in the properties panel.
Step-2: Create 3 buttons with the test on them as “sort”.
Step-3: Create another 4 input texts (boxes) and give each of them names
like r1, r2, r3, r4 respectively.
Step-4: Select the “sort” button and write the following code in the script
pane
on (release) {
a=[t1.text,t2.text,t3.text,t4.text];
var i:Number;
var j:Number;
i=0;
j=0;
var temp:String;
for(i=0;i<a.length;i++)
{
for(j=i+1;j<a.length;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
r1.text=a[0];
r2.text=a[1];
r3.text=a[2];
r4.text=a[3];
}
Step-5: Press ctrl+enter to test the movie and enter any 4 strings in the text boxes and press the button “sort” the texts entered will be sorted and will be printed in the other text boxes.