flash (macromedia):
Norberto,
[quoted text, click to view] > What I want to do is to rotate an arbitrary angle without
> ActionScript
CW (clockwise) and CCW (counter-clockwise) are great for full 360
rotations, but as you've discovered, they don't work for partial rotations.
Your best bet is to set a keyframe at yor start angle, set another keyframe
at your end angle (rotated by hand), and motion tween the frames between
them.
[quoted text, click to view] > Another particular example is the rotation of more than one
> complete turn: take the example of one and a half turn (540
> degrees), how do I rotate this amount, as the Auto rotation
> only rotates the "half turn"?
I would use CW or CCW between my first and second keyframes, then the
above suggestion between my second and third keyframes.
[quoted text, click to view] > I created a simple rotation using the CW rotate mode, so
> that the object rotates one time (360 degrees). After that
> I created a simple action that outputs the _rotation property
> on every entered frame (on(enterframe)...). I thought I was
> going to get the current angle of the object, but instead I get
> a constant value.
The on() handler is mainly for buttons. Although certain button events
will register with movie clips, enterFrame is not one of them, since
enterFrame is only for movie clips. Movie clips require the onClipEvent()
handler.
onClipEvent(enterFrame) {
trace(this._rotation);
}
The above indeed outputs a movie clip's rotation, even during tweening.
[quoted text, click to view] > Is there a way to see the motion path of an object? I'm
> not talking about motion guides, but the path created
> between tweened keyframes (in Director the motion path
> is displayed as points - one for each in-between frame)?
In Flash, the closest analogue to Director's dotted motion path is the
motion guide. (This is one of dozens of points where Director is better, in
my opinion -- and, of course, there are dozens of points where Flash is
better.)
[quoted text, click to view] > Ok, a fourth question about rotation: does the angle or a
> rotation varies between -180 and 180?
>
> _rotation: 170
> _rotation: 180
> _rotation: -170
> _rotation: -160
>
> So it does not go through 0-360 degrees. Instead of going
> to 190 degrees after 180, it goes to -170.
The angle *reported* by a movie clip is not necessarily the angle to
which it adheres. You can, indeed, set a movie clip to 350. It will rotate
to 350 degrees, but will report its rotation as -10.
[quoted text, click to view] > For calculation purposes I need to have the rotation in a
> ide angle range (even more than 360 degrees). How can
> I achieve that?
We'll probably need to hear a bit more about your requirements, and
you'll almost certainly have to work more of this out via ActionScriipt. In
this way, your angle can be maintained behind the scenes with relatively
high precision, while in the foreground, your movie clip displays the figure
visually.
I encourage you to use the newer approach to assigning event handlers.
on() and onClipEvent() are somewhat dated, having been introduced in Flash
5. Since Flash MX (Flash 6), one can assign event handlers in the following
manner:
clipInstanceName.onEnterFrame = function() {
// anonymous function statements here
}
or
function namedFunction() {
// statements here
}
clipInstanceName.onEnterFrame = namedFunction;
.... which benefits the developer in two ways: A) the ActionScript can be
organized into a single layer (generally named "scripts" or "actions"), and
B) handlers assigned in this manner can be created and destroyed at runtime
(clipInstanceName.onEnterFrame = null).
In the above approach, the ActionScript is typed into a frame rather
than directly to a movie clip or button, and of course an instance name is
required so that the ActionScript knows which object to target. Instance
names may be assigned via the Propeties inspector or, in some cases, via
ActionScript.
See the "MovieClip class" entry of the ActionScript Language Reference
to see all the available methods, properties, and events for all movie
clips. This is arguably your most important class to learn, since the
published SWF itself is a movie clip.
David
stiller (at) quip (dot) net
"Luck is the residue of good design."