Blogroll

This blog is created for education about engineering students.All the engineering students are get free downloadable books here. not only books and also different software also available here

20.Sorting and Reversing of an Array


Procedure:
step 1: Open flash 8
step 2: Select flash document
step 3: select 1st layer, 1st frame on that document and write source code on Actions Frame
step 4: To check output press ctrl+enter(test movie)

SourceCode:
var a=new Array(5);
a=[4,7,2,18,10];
ascend(a);
descend(a);
var i,j,temp=0;
function ascend(a:Number):Void
{
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
trace("Ascending order of given numbers is:");
for(i=0;i<5;i++)
{
trace(a[i]);
}
}
function descend(a:Number):Void
{
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
trace("Descending order of given numbers is:");
for(i=0;i<5;i++)
{
trace(a[i]);
}
}

No comments:

Post a Comment

Total Pageviews