flash on 2010-6-22
♥0 |
Line 44 |
Modified 2010-06-22 08:33:31 |
MIT License
archived:2017-03-20 20:00:44
ActionScript3 source code
/**
* Copyright gs1mm0ns ( http://wonderfl.net/user/gs1mm0ns )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dfmF
*/
package
{
//
//
//
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
//
//
//
public class TestBall extends MovieClip
{
//
//
//
private var myBall:BallClip;
//
//
//
public function TestBall( )
{
//
myBall = new BallClip( );
addChild( myBall );
//
var moveTimer:Timer = new Timer( 50 );
moveTimer.addEventListener( TimerEvent.TIMER , myBall.step );
moveTimer.start( );
//
}
//
//
//
}
//
//
//
}
//
//
//
import flash.display.MovieClip;
import flash.events.TimerEvent;
//
//
//
class BallClip extends MovieClip
{
//
//
//
private var xspeed:Number;
private var yspeed:Number;
//
//
//
public function BallClip ( )
{
//
graphics.beginFill( 0xff0000 , 1 );
graphics.drawCircle( 20 , 20 , 20 );
graphics.endFill( );
//
x = 20;
y = 20;
//
xspeed = Math.random( )*5;
yspeed = Math.random( )*5;
//
}
//
//
//
public function step ( timeEvent:TimerEvent ):void
{
//
if ( x + xspeed > stage.stageWidth-20 ) xspeed *= -1;
if ( x + xspeed < 0 ) xspeed *= -1;
if ( y + yspeed > 200 ) yspeed *= -1;
if ( y + yspeed < 0 ) yspeed *= -1;
//
x += xspeed;
y += yspeed;
//
}
//
//
//
}