July 2006 Archives
We're moving directly from Chapter 5 to Chapter 8 of Robert Penner's Programming Flash MX.
We're skipping Chapter 6 because it's all about event-based programming and uses the old ASBroadcaster, so there's no need to go into it. If you're interested in event-based programming after reading the chapter and don't know much about it, look into mx.events.EventDispatcher, there's a ton of documentation out there on it.
We're also skipping Chapter 7 because it focuses on the Motion and Tween classes that Macromedia licensed from Penner and wrapped into one mx.transitions.Tween class, so no need to recreate that class, although we will need to use it for the class I have converted in Chapter 8. Penner himself converted the other classes from Chapter 7 to AS2: the now famous easing equations that you can download from his site.
Chapter 8 begins to delve into the world of physics. Most of the chapter focuses on using the Vector class with the core principles--velocity, acceleration, force--and the relationships between them.
This chapter contains only one class: WaveMotion, which will be included in the com.robertpenner.effects namespace.
Documentation:
com.robertpenner.effects.WaveMotion
Source:
Penner AS2 ProFMX: Chapter 8 Classes
Dependencies:
mx.transitions.Tween
The packages for the Penner AS2 classes have been updated and my previous posts and documentation have been updated to reflect the changes. Below you will find a list of the changes that were made.
Changes:
1) The Vector and Vector3d classes have been moved from the com.robertpenner.vector package to the com.robertpenner.geom package.
2) There is no longer a com.robertpenner.vector package.
3) The Constant class no longer exists, it has been merged with the Utility class into the new MathUtil class.
4) The MathUtil, Degree, and Polar classes have been moved from the com.robertpenner.math package to the com.robertpenner.utils package.
5) There is no longer a com.robertpenner.math package.
There is always a fine line between how long you should devote to the planning stages of a project and when you just need to crank through stuff and get it out. With this Penner AS2 project that I've undertaken, I wanted to start releasing as soon as I made the announcement. Even though I had spent plenty of time up front thinking through the book and all the different classes that would need to be converted, I didn't give the package names that much forethought. Penner had already come up with most of the class names (although in certain circumstances I have tweaked the name where I thought appropriate), but in AS1 there was obviously no need to think through package names.
The package names I initially chose for the classes I've released to date made sense at first, but as I started moving my way through the book I found areas where I wasn't thinking broadly enough. I've decided to go back and update these packages to follow standards set in place by Macromedia (Adobe) for the naming conventions of their packages... and to be the most up-to-date, I have decided to follow the AS3 package conventions, which vary slightly from the Flash 8 package conventions.
The vector classes will now be under the geom package and the math classes will be under the utils package and some actual class names might be tweaked slightly as well.
As soon as I get everything updated (including the previous posts), I will make a new post with all of the details. Sorry for any inconvenience, but I think in the long-run this will make more sense and allow the robertpenner namespace to remain flexible.
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.
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);
}
Chapter 5 of Robert Penner's Programming Flash MX extends upon what was learned in Chapter 4 by adding a third dimension to vectors.
This chapter contains two classes: Vector3d, which will be included in the com.robertpenner.geom namespace, and Graphic3d, which will be included in the com.robertpenner.display namespace.
Documentation:
com.robertpenner.geom.Vector3d
com.robertpenner.display.Graphic3d
Source:
Penner AS2 ProFMX: Chapter 5 Classes
Dependencies:
Penner AS2 ProFMX: Chapter 4 Classes
Penner AS2 ProFMX: Chapter 3 Classes
I have fixed a small bug that caused the FlashPaper component to not process a new documentPath if set dynamically before the component had completely loaded.
Description:
The FlashPaper component simplifies the process of working with the FlashPaper API and adds functionality either not documented or not provided in the API.
Installation:
- Unzip FlashPaper_0.7.1.zip
- DoubleClick on FlashPaper.mxp to install with the Extension Manager.
Documentation:
FlashPaper Component Documentation