Plot the Points
Here is a property in flash actionscript not everyone knows; As a matter of fact, even I learnt it just before making this movie. It goes like this: Because we have assigned a array slot to each movieclip, each array becomes like an object. Similar to java, we can have variables for each object, apart from their properties. That is, we can have 3 variables x,y and z for each array element to store the co-ordinates of each vertex. So let's put it to use. What we are going to do now is give each vertex its position in the 3 dimensional world. Because flash is not equipped to do this in any decent manner, we have a boring part of typing an awful lot of lines. We have to give the x,y,z co-ordinates for each vertex. In this tutorial, however, it is going to be easy as all you have to do is copy the following code and paste it in the action script window.
- Now, we need to give the location of all the vertices. So, just copy the following code into the actionscript window of Flash:
vertex.x = 0; vertex.x = -100; vertex.x = -150; vertex.x = -150; vertex.x = 0; vertex.x = 100; vertex.x = 150; vertex.x = 100; vertex.x = 150; vertex.x = 0; vertex.y = 0; vertex.y = 0; vertex.y = -100; vertex.y = 0; vertex.y = 100; vertex.y = 150; vertex.y = 100; vertex.y = 0; vertex.y = -100; vertex.y = -150; vertex.y = 0; vertex.y = 0; vertex.z = 0; vertex.z = -100; vertex.z = 0; vertex.z = 100; vertex.z = 0; vertex.z = 100; vertex.z = 0; vertex.z = -100; vertex.z = 0; vertex.z = -150; vertex.z = 150;As you can see, the values and the number of lines itself will differ for each object and you have to experiment with this to get a rough idea of where a -100,-100,-100 point will lie after rendering. I can explain that to you, however, that will be beyond the scope of this tutorial. And the .x, .y, .z are mere variables which can be assigned to an object array.
- Remember when you were a kid and played those 'Join the Dots' games in the books? Well, you are going to do that again. This time, it will be in 3 dimensions. Here too, you will use the object array logic to store the variables. All you have to do is specify the two points to which each line is connected. So, we will need two variables a and b for each line. We will use the line array. Just copy the following code and paste it into the flash actionscript window:
line.a = 0; line.b = 1; line.a = 0; line.b = 2; line.a = 0; line.b = 3; line.a = 0; line.b = 4; line.a = 0; line.b = 5; line.a = 0; line.b = 6; line.a = 0; line.b = 7; line.a = 0; line.b = 8; line.a = 0; line.b = 9; line.a = 0; line.b = 10;The values assigned to them might be confusing, but if you see, they will say the number of the vertex in the vertex array to which they are connected. For example, the line 'line.a=0' says that it is connected to the vertex contained in the vertex array at the location of 0. Now, if your imagination powers are excellent and you are good in math, you will see that all this means to describe a err... flower like object.
Be sure that all the scripts mentioned in this page and all other previous pages are all placed in order in the first frame's actions. Also, place the upcoming scripts in the first frame itself, until or otherwise, specified.
|» Level Advanced|
Rating: 9 Votes: 1241
|Age: 14 Profession: High School Student Location: Chennai, India(Not Indiana). Just doing it for fun. Ready to do small Freelance jobs.|
|Download the files used in this tutorial.|
|Download (51 kb)|
|More help? Search our boards for quick answers!|