Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
We now come to arrays. arrays are a very useful scripting element. They're very similar to variables with one important different. Variables can only hold one value at any given time while arrays hold multiple values in a single instance. Let's look at an example from a script that we've already worked with. When we worked with filters and creating filters using ActionScript, we worked with arrays. Here is an example of a filter Array. I'm creating a new Array with these three values in the Array; drop shadow, bevel and blur. So you can see it's like a variable but it holds multiple values there. Also Flash used arrays to copy our motion tween to ActionScript previously. Here is that example of converting animation to code. If we open up the Actions Panel here, you can see that this script is actually dominated by arrays. Here we have our Array values; add property to the Array X direction, Y direction, scale X, scale Y. In this case each enter or Array entry represents a changing property of the animation. Here represents a change in position in the X direction. Here a change in position in the Y direction, up and down. Here the X scale value is changing per frame and here the scale in the Y direction or the sides in the Y direction is changing. So in this case both the X and the Y position is changing as well as the size is changing as this object moves from frame to frame across the stage. But let's back up a bit and look at a much more simple example. I've a roster let's say with student names and phone numbers in grade book. This roster might look like this where I have John, Mike, Jan and then 20 other students with their phone numbers next to it. To write this in ActionScript we could do it using an Array variable, my roster Array equals new Array. I go ahead and set up the values in the Array. Roster position zero, which is actually the first position, equals John, then Mike, then Jan, then all the way out to number 19, which will be Sam. Notice that I have 20 members in my Array, only go up to 19 because I have a zero position. A little bit confusing there so I'm going to start from the zero position so 20 positions in the Array is actually represented in the Array by position 19. We could also write the Array information like this, a little bit more compact, takes up less space. I think this is actually a better way to introduce you to arrays. It kind of gives you that feeling or that essence of an Array as a list of variables here, a collection of variables. We can also write it like this to save space. Now, if we wanted to retrieve values in the Array, we would do it with a script like this: variable second student colon string equals my roster and then inside of these square braces the number 1. So again, arrays start with the value zero so this would retrieve or actually get the value Mike in this arrow and then place it inside of this variable called second student. Notice that I'm identifying the type of variable. It's going to be a string variable so that's why you need the quotation marks up there in my Array. Let's now move on to the next movie and let me review how to create custom methods in ActionScript 3.0.
| Course: | Adobe Flash ActionScript 3.0 for Designers |
| Author: | James Gonzalez |
| SKU: | 34060 |
| ISBN: | 1-935320-82-3 |
| Release Date: | 2009-11-09 |
| Duration: | 9.5 hrs / 101 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |