So far we have seen how to use Actionscript 3.0 to create effects and animations.
We have seen how trigonometry, the Pythagorean theorem, collisions and much more.
Now I would like to open a chapter on the kinematics applied to Actionscript 3.0.
For those who do not know, the kinematics is a branch of mathematics that deals with movements bodies / objects but without the use of force or the masses and posed the problem of finding the causes accounting for such movements.
For those who want to deepen the discussion, leave a link to Wikipedia:
http://en.wikipedia.org/wiki/Kinematics
So this is speed and direction.
It seems very simple (and actually we'll see it is ) but kinematics can reach extremely complex formulas.
Often the kinematics is applied in 3D softwares but we'll see in 2D ( since Flash CS3 has not 3D engine) and will be a beautiful view.
The kinematics is of two types: direct and inverse.
The direct dealing with movements that originate at the base of the system and move on free end (like a segment).
The inverse is handled to the contrary, the animation originates from free end and back at the base of the system.
We see the first example that relates move as a segment ...
How to move a segment.
Let's start to see how to move a segment with Actionscript 3.0 .
First of all I draw the segment.
Transform it to MovieClip and give it instance name: "segment_mc".
Give it the registration point at the left fulcrum point of the segment, see picture below:
Drag a Slider component on the stage and give it instance name "my_slider".
Give it a vertical positio and minimum value 0 and maximum value 90.
Add the THUMB_DRAG listener to the Slider and here we go:
Used code:
Source files:Code:import fl.controls.SliderDirection; import fl.events.SliderEvent; my_slider.direction=SliderDirection.VERTICAL; my_slider.rotation=270; my_slider.minimum=0; my_slider.maximum=90; my_slider.value=0; my_slider.addEventListener(SliderEvent.THUMB_DRAG,onChange); function onChange(evt:SliderEvent):void { segment_mc.rotation=evt.target.value; }
Bookmarks