Thursday, June 17, 2010

How to Bounce a Ball using only ActionScript in Flash 8 with 3 lines of code

Open Flash 8.
Draw a ball.
Choose "Convert to Symbol" and Create a MovieClip .
Instance Name: ball_mc

Write the Following Actions Script [ Press F9 to open the Action Script Panel ]

import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(ball_mc,"_y",Bounce.easeOut,ball_mc._y, 280,3,true);


For Details : Flash 8 Bouncing Ball Animation

Result:









Another code to create play button to play the animation :

import mx.transitions.Tween;
import mx.transitions.easing.*;
// new Tween(obj, prop, func , begin, finish, duration, useSeconds )

var temp:Tween = new Tween(ball_mc,"_y",Bounce.easeOut,ball_mc._y, 280,3,true);

this.play_mc.onRelease = function():Void
{
temp.start();
}

No comments:

Post a Comment

Train Schedule Info

Subscribe

Quote

"There are two blessings which many people lose: (They are) Health and free time for doing good."
[Ref: Sahih al-Bukhari - Hadith number:6412]