Actionscript in the array
Related Tags:
Software Environment: Flash 5
If you sense our interest in the array, then you must be aware variable bar. Variable data is carrying containers, data can be digital, or string is a boolean value.
And the array variable is the same as similar data containers, but it can contain more data, each Element (part of the data) were attached to an index.
Array can be used to preserve your script and organizational structure, which is usually used to organize some in certain areas, some associated values, these values using an index value and an array of other elements separate. Below you can use this method to define three variables::
Quote1 = "Flash is cool!"
Quote2 = "Flash is my favourite program"
Quote3 = "Flash rules"
Clearly there is a better way to achieve the above example is the use of the array. There are many ways to create an array, but I first Display is one of the most simple method:
Name_of_array = new Array ()
Therefore, we want to use an array, it would use this:
Quotes = new Array ()
Very good, now we have an array, but the problem is that there does not have any data, it is useless, so we are the data we put inside the array, we use an index number to define it in a few Group position.
We can use the following method to the first element into the array:
Quotes [0] = "Flash is cool!"
I have to say that in the Flash 5 array index is based on the subscript 0, meaning that the array with the first element of its index is 0.
Therefore, we can be in our array elements in the second Add a data:
Quotes [1] = "Flash is my favourite program"
Tianmen use the following Syntax can be an array of all elements:
Name_of_array [index] = value
Note: The above name_of_array array is the name you, is what you want to index your data in the array position.
Therefore, we created earlier use of variable code:
Quote1 = "Flash is cool!"
Quote2 = "Flash is my favourite program"
Quote3 = "Flash rules"
They can also be written this way:
Quotes = new Array ()
Quotes [0] = "Flash is cool!"
Quotes [1] = "Flash is my favourite program"
Quotes [2] = "Flash rules"
We can also adopted the following syntax to create:
Name_of_array = new Array ( "value1," "value2", "value3")
This is a realization of his code, value1 is the first element of the array is an array value2 of the second element, and so on.
We use the following syntax we used to create the array:
Quotes = new Array ( "Flash is cool!" And "Flash is my favourite program," and "Flash rules")
Now we know how to create arrays, and how to use it in the following syntax of this can be the same to create a few Aunt:
Name_of_array = [ "value1," "value2", "value3"]
And this is no different in front of the use of an array of like (new Array ())
Therefore, we can use this to create an array of code as follows:
Quotes = [ "Flash is cool!" And "Flash is my favourite program," and "Flash rules"]
I do not care how masses, but I still prefer to use this method to create a final array, it is so simple.
Now we know how to create arrays, but sometimes you want to visit you in your script array, ah We are fortunate that there is a means to achieve it:
Name_of_array mynewvariable = [index]
Then we want to go as a new variable for the value of the first element of the array values if requested to do so:
Firstquote quotes [0] =
Entitled firstquote new variable value is the "Flash is cool!"
In the script array of ideas to achieve if we are to come to all of the array elements, but we do not know the number of array elements ah, Flash is better for an array of settings, as a number of attributes and , one of the attributes that can be drawn for the Length of elements in an array of numbers.
Grammar as follows:
Myarraylength = name_of_array.length
Above this code creates a new variable, there is the value you specify an array of like (name_of_array) the number of elements.
We cited in the case of an array, use the following code by the number of elements in an array:
If the quotes are an array of less
Len = len quotes.length this variable is the value of the length of the array
The length of the array is the highest index value plus 1. If it is the highest index value of 2 then the length of the array is 3, that is to say it contains
Three elements, because the Flash 5 is based on an array subscript 0.
Now we know how to use the array Length attribute, use the following script can be drawn in several grade the value of all the elements.
For (z = 0; z <name_of_array.length; z) (
Write (name_of_array [z])
)
Let us step by step to analyze the above code.
First create a temporary variable z
Z = 0
The following code is a cyclical conditions, when variable z is less than the length of the array elements on the cycle
Z <name_of_array.length
Z variables before making its own incremental increase 1;
Z
You can here Add to the code you need they will be implemented (name_of_array.length value),
For (z = 0; z <quotes.length; z) (
...
)
Associative arrays:
Associative array can provide an additional method of information storage, you can use it as a realization of a string array subscript instead of a number, this will be more easy to remember.
This is the inconvenience in the cycle can not be used because it is not a numerical value.
Associative array and the definition of the array is the same, mutatis mutandis, and the only difference is that it used as a string subscript Index
Look at this example, we define a vehicle array:
Mycars = new Array ()
Mycars [0] = "306 peugoet"
Mycars [1] = "citreon saxo"
Mycars [2] = "ford fiesta"
This is the associative array format:
Mycars = new Array ()
Mycars [ "fast"] = "306 peugoet"
Mycars [ "sporty"] = "citreon saxo"
Mycars [ "old"] = "ford fiesta"
Index values do with characters sometimes useful, but in the loop to retrieve the array is very inconvenient.
Now that should be of this type in the value of the array, you have to use string as has been indexed, in the light of the above examples write:
Mycars mysportycar = [ "sporty"]
The result is the value of that variable mysportyca "citreon saxo"
- The Flash ActionScript a classroom Record
- ActionScript some "unknown" skills
- Common ActionScript Suchabiao
- Actionscript in the local connection
- Flash MX 2004 ActionScript by Guide
- Flash ActionScript 2.0 Essentials
- Actionscript in the array
- Actionscript Optimization Guide
- Shows ActionScript code optimization
- Actionscript in High Path
- Learning ActionScript entry - voice control
- Flash ActionScript Learning: AS written to the MC
- Beginners to all the recommendations of ActionScript
- ActionScript use an array Summary
- ActionScript learning: AS-written scroll
- ActionScript color graphics and preparation
- ActionScript of Essentials: drag the ball
- Flash ActionScript 3.0 Summary
- Flash Actionscript the implementation of the order scripts
- FLASH ActionScript language explain




