|
|
|
How to create randomly flying away movie
Author: Sergiy Kamenyev | Email Website : www.vemix.com
Advertisement
This lesson is for the people, who know basic algebra, geometry and intermediate in Flash.
We shall create the movie in which a button-movie and its destination point will appear in random places of the scene. If you click on the button, it will move to the destination point by random trajectory and the button size will decrease to 0. After this, the button will call callback function on the _parent, and everything will be from the beginning.
Let's discuss design of the button-movie.
We put there movie with flying bird and the rectangular button just for "hand cursor" will appear under our movie. We also have seperate movie clip "timer" here, as we like, just to find easily all the events in this movie. We have the action code for the "timer":
onClipEvent (load) {
_visible=0;
}
onClipEvent (enterFrame) {
_parent.fnOnEnterFrame();
}
The action code for the button is:
on (release) {
flyAwayRandomly();
}
The function flyAwayRandomly() is located on the first and unique frame of our movie clip.
The idea of finding random trajectory is to build the third degree polynomial on the coordinates, the center of what is located in the initial point of our movie, the "X" axis coincides with the segment between initial and destination points, and the roots of the polynomial are initial point, destination point and randomly picked point between them. After all the polynomial will be created, we will push our movie to move by it, and convert coordinates to usual by these rules:
x = x' · cos α - y' · sin α
y = x' · sin α + y' · cos α,
Download Source File
We hope the information helped you. If you have any questions
or comments, please don't hesitate to post them on the
Forums section
Submit your Tutorial at Click Here
|
|
|