Dot
再利用できる点クラス!
オブジェクト指向の入門に?
なんて
...
@author tkinjo
♥0 |
Line 52 |
Modified 2009-06-11 09:52:28 |
MIT License
archived:2017-03-20 02:32:43
ActionScript3 source code
/**
* Copyright tkinjo ( http://wonderfl.net/user/tkinjo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ov8Q
*/
package
{
/**
* 再利用できる点クラス!
*
* オブジェクト指向の入門に?
* なんて
*/
import flash.display.Sprite;
import flash.events.Event;
[SWF(width="465", height="465", frameRate="60", backgroundColor="0xffffff")]
/**
* ...
* @author tkinjo
*/
public class Main extends Sprite
{
private var dot:Dot;
/**
*
*/
public function Main()
{
dot = new Dot( mouseX, mouseY );
addChild( dot );
addEventListener( Event.ENTER_FRAME, enterFrameHandler );
}
/**
*
* @param event
*/
private function enterFrameHandler( event:Event ):void {
dot.x = mouseX;
dot.y = mouseY;
}
}
}
import flash.display.Sprite;
class Dot extends Sprite {
/** --------------------------------------------------
* 半径
*/
public function get radius():Number { return _radius; }
/**
* @private
*/
public function set radius(value:Number):void
{
_radius = value;
draw();
}
private var _radius:Number;
/** --------------------------------------------------
* 色
*/
public function get color():uint { return _color; }
/**
* @private
*/
public function set color(value:uint):void
{
_color = value;
draw();
}
private var _color:uint;
/**
* x 方向の速度
*/
public var vx:Number;
/**
* y 方向の速度
*/
public var vy:Number;
/**
*
* @param x
* @param y
* @param vx
* @param vy
*/
public function Dot( x:Number = 0, y:Number = 0, radius:Number = 5, color:uint = 0, vx:Number = 0, vy:Number = 0 ) {
this.x = x;
this.y = y;
this.radius = radius;
this.color = color;
this.vx = vx;
this.vy = vy;
}
/**
*
*/
public function draw():void {
graphics.clear();
graphics.beginFill( color );
graphics.drawCircle( 0, 0, _radius );
}
}