First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
Search tutorials
Author: Andross

Introduction

As you continue to work on various Flash applications you come across many challenges that aren't always a big deal, but sometimes you can't overcome them. Although it may be true that I face frequent challenges, I am able to find a solution because I think about it and try to find it on paper. I cannot explain the process that I go through in my head, but I can tell you that it gets confusing when lots of thoughts are going through your mind.

What is sortArray( )

The function sortArray ( ) is one of the many functions I created while working with ActionScript. It all started when I was trying to order a set of numbers from least to greatest, and there was no function in Flash that could do that so I had to figure it out myself. An example would be this.

var numbersArray = [2,5,10,4,8,14]

What the sortArray ( ) does is return an array with the numbers ordered from least to greatest like this.

sortArray ( numbersArray ) = [2,4,5,8,10,14]

In this tutorial I will try to explain how the function works or if you want, you can just grab the code and leave.

How to use sortArray( )

Well let me just show you an example of how it would be used. Lets say I have an array called 'numbersArray' with my own set of numbers.

var numbersArray = [4,5,1,8];

Then I have an empty variable that will hold the newly ordered array.

var numbersArrayOrdered;

Now I use the function.

numbersArrayOrdered = sortArray ( numbersArray );

If I trace 'numbersArrayOrdered' you get this output.

[1,4,5,8]

Now lets see the code for the function.

» Level Intermediate

Added: 2004-08-24
Rating: 4 Votes: 12
(10 being the highest)
» Author
16 years old. Likes Flash. male.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: doc_chin7
» Description:

The flash's horizontal road drive was done in CS4 and was upgraded to CS6. The car responds to right/ left key and flash will auto-generate the movement of roads from left-right or right-left based on random number. Have fun driving in this virtual environment and avoid other cars... :) If you are creative, a road driving game can be created from it.

Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.