Vectors
Video Transcript
00:00All right, as promised we have a bonus extra feature very very very simple very very cool
00:06By the way, this is the first thing we're doing that actually isn't about action strip 3 period
00:10This last video is about action strip 3 with flash player 10 or above
00:15Now arrays are very friendly useful. We've been working with them for a long time
00:20There's another thing that's called vectors if you know what vectors are you could skip this video if you don't know what vectors are
00:27Hang on with us within two three minutes
00:28You're gonna know what they are arrays enabled enabled us to put whatever we wanted into them
00:33We didn't have any defined rules to what could be put it within them
00:38Vectors on the other hand are exactly like arrays
00:41The only difference is is that we tell the vector what could go inside now the advantage of that is also if we put something
00:47Else we'll get a compiling error, but beyond that it's going to take less memory
00:51it's gonna take less memory because now flash and the compiler and the operating system don't have to keep
00:57Room for anything. They just have to keep room to specific things
01:02Meaning that they're not gonna need to use as much memory to store things up. So let's see how to create a vector
01:07So first of all, the way we define a vector is really weird, but with it very simple
01:12so we first start with the words vector and
01:15The vector with the uppercase V like everywhere else and by the way vector just pretends
01:20It's an array only a specific array that could only contain a specific thing
01:25Now we put a dot and we open kind of like an HTML bracket, you know those triangles and inside of it
01:31We put of it what we put in it what we want in our case
01:34We want it to be only I playable items and then we close our triangle
01:40Triangular bracket so we open a triangular bracket close a triangular bracket very very weird
01:47Don't ask me why it is weird
01:49Alright, so we decide do we define it as a vector of I playable elements all that's left for us to do in line 16
01:56Where we were creating a new array. It's instead of that to create a new that vector I playable open closed brackets
02:04And now that's all the code we have to change
02:06We don't have to change anything else
02:07Now if we run our application is going to still run in the same way where the I playable is once every five seconds would start
02:13Playing so in this case after five seconds the fire is playing and the functionality is exactly the same
02:19The only thing we got out of it is now it's using less memory to do what we want it to actually do
02:24Alright now I wanted to just say one more thing about vectors vectors are incredibly simple
02:31And they're really were created to enables to enables us to basically
02:37improve our
02:39overall
02:40Functionality and literally there's a few other stuff that we could do with a vector in its initial parameters
02:45One of them is we're capable of defining how many items exactly do we want to have in our scenario?
02:51We don't need to so our first parameter
02:54We could say that we're gonna have ten elements inside and we could say it's true
02:58Which basically will mean that we cannot add more things and again. This is an advantage of
03:05Performance because now flash doesn't have to worry about what of memory that it needs to store if you want to add things it now sets
03:11It to be zero knows exactly how many memory it's going to take and it's never gonna be more than that in our scenario because we don't
03:18Really know in advance how many elements we're going to have and because we're actually pushing our elements in using the add playable
03:24Function which inside of the add playable function. We're just pushing our items inside
03:29Then because of that we are we just it doesn't make sense to us to lock it in and the last thing we probably want to
03:35Do is just to make sure that our naming convention works is I'm going to go to that
03:38I a playable items, and I'm just going to change it from a to v so I'm sorry
03:43No for sure always that it's a vector, and I will replace all I'll be extremely happy
03:47I'm going to click I'm going to save it and that completes our
03:51Our training on poly from ism and interfaces in the next video
03:56We'll just do a really quick summary and kind of a wrap-up of explaining why interfaces are important
