Thanks to all the great tutes I’ve found I’m working with some tutorial codes from camera views. I’ve run into difficulty with an actionscript analog clock face I wish to use as my perloader and between page transitions.
I want it to start out 10% of complete size at bottom center stage … zoom out to 100% as it tweens a semi-circle motion path clockwise to full stage size, center stage, and rotates 360 degrees and then stops.
While the clock face is tweening and morphing into shape I want the minute and hour hands to make 1 3/4 revolutions starting from 12:00 so the hands on the clock face stops moving at 10:00 … passing 22:00:00 of time from start to stop.
I’m lost at writing the function(s) for things to occur. Like how do I get the function to count from 0 to 660 and then stop the hour hands at 10:00 ???
// create circle movieclip on layer 1 to contain all 3D elements
// and center it on the screen.
this.createEmptyMovieClip("circle", 1);
circle._x = 300;
circle._y = 200;
// Draw hoursHand movie clip on layer 20 and minutesHand on layer 30
// AND move registration to (0,0) for _rotation
circle.createEmptyMovieClip("hoursHand", 20);
circle.hoursHand.lineStyle(6, 0x000000, 100);
circle.hoursHand.moveTo(0, 0);
circle.hoursHand.lineTo(0, -125);
circle.createEmptyMovieClip("minutesHand", 30);
circle.minutesHand.lineStyle(5, 0x000000, 100);
circle.minutesHand.moveTo(0, 0);
circle.minutesHand.lineTo(0, -156);
// Rotate the hand movie clips 1 revolution at x frames per second
// then stop at 10 o'clock
circle.onEnterFrame=function(){
minuteSpeed = 5;
this.minutesHand._rotation ++;
this.minutesHand._rotation += minuteSpeed;
hourSpeed = 4.5;
this.hoursHand._rotation ++;
this.hoursHand._rotation += hourSpeed;
} stop();
Then with this senocolur 3D code I’d like to morph and tween from 10% to 100% expanding to full size
circle.onEnterFrame = function () {
???
// focal length to determine perspective scaling
focalLength = 300;
// x, y and z properties to represent a 3D point.
make3DPoint = function(x,y,z){
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
// x and y properties to represent a 2D point.
make2DPoint = function(x, y){
var point = new Object();
point.x = x;
point.y = y;
return point;
};
// conversion function for changing an array of 3D points to an
// array of 2D points which is to be returned.
Transform3DPointsTo2DPoints = function(points, axisRotations){
// the array to hold transformed 2D points - the 3D points
// from the point array which are here rotated and scaled
// to generate a point as it would appear on the screen
var TransformedPointsArray = [];
// Math calcs for angles - sin and cos for each (trig)
// this will be the only time sin or cos is used for the
// entire portion of calculating all rotations
var sx = Math.sin(axisRotations.x);
var cx = Math.cos(axisRotations.x);
var sy = Math.sin(axisRotations.y);
var cy = Math.cos(axisRotations.y);
var sz = Math.sin(axisRotations.z);
var cz = Math.cos(axisRotations.z);
// looping of all the points in the transform process
var x,y,z, xy,xz, yx,yz, zx,zy, scaleRatio;
var i = points.length;
while (i--){
// apply Math to making transformations
// based on rotations
// assign variables for the current x, y and z
x = points*.x;
y = points*.y;
z = points*.z;
// perform the rotations around each axis
// rotation around x
xy = cx*y - sx*z;
xz = sx*y + cx*z;
// rotation around y
yz = cy*xz - sy*x;
yx = sy*xz + cy*x;
// rotation around z
zx = cz*yx - sz*xy;
zy = sz*yx + cz*xy;
// determine perspective scaling factor
// yz was the last calculated z value so its the
// final value for z depth
scaleRatio = focalLength/(focalLength + yz);
// assign the new x and y
x = zx*scaleRatio;
y = zy*scaleRatio;
// create transformed 2D point with the calculated values
// adding it to the array holding all 2D points
TransformedPointsArray* = make2DPoint(x, y);
}
// exist after the rotation and scaling
return TransformedPointsArray;
};
pointsArray = [
make3DPoint( -x-,-x- ,-x- ),
];