Character elastic movement
Flash game characters doesn’t have to move only in standard way, press left arrow key to move left, right arrow key to move right, space to jump etc. In this new flash game, main character (hero) will move differently. Hero will be dragable and on click, he will perform elastic move. Start position and destination position will be symmetrical in relation to Stage center. Enemy can be destroyed only if mouse is not pressed, otherwise, hero health will decrease.
Now, code. First we import related classes:
import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.transitions.easing.*;
We need to define simple onPress, onReleaseOutside and onRelease methods for movie clip of our hero, mcHero. Method onRelease has two functions, findSimPoint() and doTween(). It is obvious that findSimPoint() calculates symmetrical point of hero x and y in relation to Stage center. DoTween(), well, performs the tween! Code comes with comments.
Download hero.fla






