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

Welcome

Author

It is IT related blog site and Experiences of Zahid Bin A. Rouf, which has posts on technology,tips and tricks,links,troubleshoot,tutorials,computer related suggestions,reviews

Subscribe

Like Us

bangladesh-data
Bangladesh-data Blog
CodeInclude
CodeInclude Blog
tictactoe
TicTacToe Game

Bangladesh Info

CodeInclude

"There are two blessings which many people lose: (They are) Health and free time for doing good."

~Narrated by Ibn 'Abbas
~Said by Prophet Muhammad (sallallahu alayhi wasallam)
[Ref: Bukhari Hadith:Volume 8, Book 76:Softening the Heart, Number 421 ]

Pageviews last month

Flickr