Below you will find the updated code for the example at the end of Chapter 5 to show you how to use the two classes from the Chapter 5 Penner AS2 post.
Add the following code on the first frame of a blank MovieClip centered on the stage.
Make sure to have another MovieClip exported for ActionScript with the linkage name of “dot” in the library to be used as the actual 3d graphic.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import com.robertpenner.display.Graphic3d; function getWallPoints (width:Number, height:Number, xDivisions:Number, yDivisions:Number):Array { var x:Number; var y:Number; var z:Number; var pts:Array = new Array(); var depth:Number = 0; for (var i:Number = 0; i <= xDivisions; i++) { for (var j:Number = 0; j <= yDivisions; j++) { x = width * (i / xDivisions - .5); y = height * (j / yDivisions - .5); z = 0; pts.push(new Graphic3d(x, y, z, this, "dot", depth++)); } } return pts; } function arrayRotateXY (particleArr:Array, angleX:Number, angleY:Number):Void { var i:Number = particleArr.length; while (i--) { particleArr[i].position.rotateXY(angleX, angleY); particleArr[i].render(); } } var wall:Array = getWallPoints (100, 100, 4, 6); this.onEnterFrame = function() { this.arrayRotateXY (wall, _ymouse/20, _xmouse/20); } |
Hey Mark,
Just wanted to say “you rule!”.
I have ported various bits and pieces of Robert Penner’s code to AS2 classes as I’ve needed it but nothing as dedicated and thorough as the job you’re doing. I’d offer some of the code but you’ve already ported all the bits I’ve ported!
Keep up the great work. I wish I could offer to help but things are a bit chaotic right now. I’ll be sure to let you know if I can free up some time to contribute.
(Thanks also to others who are contributing)