# 3D with Flash

Hello people,\rI wondered : what’s the main idea behind 3D in Flash. I mean, I’ve seen a lot of scripts to make rotating squares or triangles or whatever, but never managed to understand how they were made. Any 3D expert ?\r\rpom

i struggled with many tutorials but never got anything happening until i lifted code from this page. specifically the examples by guy watson.

Thanks Supra. One question though : what do the 3d_draw movies have to do with 3D ?\r\rpom

hmm, i’m not sure, and the link is broken from here right now, i’ll try again later.\r\rmore specifically, the code i lifted from 3d_spiral.fla

do you know the concept of addition of angles and stuff? 3d involves some heavy-duty math. i struggled with it for about a week before being able to write script without reference. if you’re good in math, then we can be off to a good start with your learning, if not, i’ll find that site that helped me understand it. it’s really not that hard once you uderstand it. but there are still some things that i am trying to figure out.

Well, yes, no bragging, I’m good at math, but I’ve never done any geometry. Topology, vectorial spaces, differential equations, I can handle. But draw a line, and I can’t remember what my name is. Doh ! Maudit !\r\rpom

Supra, your link to this knowledge base is just GREAT!!\rWhere do you find this stuff?\rThanx anyway…

merci !

OK, so in order to understand the 3d spiral, I figured I had to look at 3d spring first. Verdict is : I can’t understand it. The code in the viewer is all right, but the projection function I can’t understand.\rMovieclip.prototype.projection=function(){\r&nbsp &nbsp &nbsp &nbsp pers=_root.d/z //so this must be the perspective effect, but how did you get to that formula ? And what does it represent ?\r&nbsp &nbsp &nbsp &nbsp _x=persx //why ?\r&nbsp &nbsp &nbsp &nbsp _y=-persy //idem\r&nbsp &nbsp &nbsp &nbsp _xscale=_yscale=pers*100\r}\rAnd last thing. Flash considers that the z axis goes through the screen (not out of the screen), right ?\r\rAnd Thoriphe, I’d really appreciate it if you teached me the 3d basics.

its a little too confusing for 12 year olds! ive been working on if and uh… the other thing, hit tests, 3dnes… man its too much hard work and stuff… I cant figure anything out because its all too confusing for meee! ( though im way past the basics i cant get into advanced ) oo one more thing how you put flashes into this text box thing? i cant seem to be able to do it .\r

First of all, what Firedrake asked about putting the animations in the box guys, that would be nice to know how to do.\r\rSecondly,\r Firedrake, You don’t seem to see it because your only 12 as you say. Your frustration is the biggest hurdle. When you get frustrated, as you undoubtedly will over and over, take a quick break, let your forehead cool down, and then return, not expecting NOT to get frustrated again, but that you will learn bits and peices along everyone of those journeys. And at your pace, with your knowledge, you will either be making excellent money building ultra cool websites, or you will be in Jail for hacking into the Pentagons missile Library, probably the former, as hacking is much more frustrating. Relax, and give yourself the credit due…And pace yourself, lest you wear yourself out.\r\rpj\rWho also counsels 12 year old genious’s on the side (bills in the mail)\rAlso, take a look at my name that phollows…and I am 39

pers=_root.d/z;\r\rhmm, looks like something’s missing. come to think of it, i think i changed mine from when i lifted it, mine reads:\r\rpers = (z+_root.d)/_root.d;\r\rthat makes more sense. ; )\r\r_root.d is a constant that defines how much perspective there is. it’s usually a moderately large number, it needs to be a fair amount bigger than z. the larger _root.d is, the less the perspective effect, it’s an inverse thing.\r\rsee how as z gets larger, pers gets larger, and vice versa? but not by too much. say _root.d=600 and the z for a given vertices is 30. that leaves you with 630/600, which is 1.05.\r\r_x=persx;\r_y=pers-y;\r\ri’m not sure why the negative on y. i’ve made them both positive in my code.\r\rimagine you’ve two points are 10m apart. if you were close to them they’d appear very far apart, you’d have to turn your head to see one then the other. now imagine them from 100m away, well now they seem really close together. by multiplying the x,y values by the pers (which was derived from the z) we make points that are further away appear closer together, and vice-versa.\r\ri’m not sure what the difference is between going through the screen and out of the screen(?). but i think you’ve got it right. big z = close to you, small z = far away.

Yeah, well, that’s what I thought.\rwith : pers=_root.d/z\rthe greater z, the lower pers, hence the smaller the dot, which isn’t logical.\rpers = (z+_root.d)/_root.d; works too, but as you said, it’s much less dynamic than the other one.\r\rOK, so you’re explanation is very intuitive. It works, very well, but I’ve had the fisfortune to look at the code for a spinning square, and the equations for rotation in 3D looks a lot more convincing (even though a lot less understandable).\r\rGoing in the screen, out of the screen, you know… 0] \r\rpom