sbcr_1_1
sbcr_1_1
♥0 |
Line 74 |
Modified 2010-11-02 16:05:06 |
MIT License
archived:2017-03-20 01:19:24
ActionScript3 source code
/**
* Copyright ushisantoasobu ( http://wonderfl.net/user/ushisantoasobu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u1fB
*/
package {
import flash.geom.Point;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
public var ball_num:int = 12;
public var arr:Array;
public var rollover:Boolean = false;
public var timer:Timer;
public var basic_bal:ball;
public function FlashTest() {
basic_bal = new ball(0x000066);
addChild(basic_bal);
basic_bal.x = 40;//this.stage.stageWidth / 2;
basic_bal.y = this.stage.stageHeight / 2;
arr = new Array();
for(var i:int = 0; i < ball_num; i++){
var bal:ball = new ball(0x00FF00);
arr.push(bal);
}
for(var j:int = 0; j < arr.length; j++){
arr[j].x = this.stage.stageWidth / 2;
arr[j].y = this.stage.stageHeight / 2;
addChild(arr[j]);
}
basic_bal.addEventListener(MouseEvent.MOUSE_OVER, mouseoverEventHandler);
basic_bal.addEventListener(MouseEvent.ROLL_OUT, rolloutEventHandler);
timer = new Timer(33);
timer.addEventListener(TimerEvent.TIMER, timerEventListener);
timer.start();
}
public function mouseoverEventHandler(e:MouseEvent):void{
rollover = true;
}
public function rolloutEventHandler(e:MouseEvent):void{
rollover = false;
}
public function timerEventListener(e:TimerEvent):void{
for(var i:int = 0; i < arr.length; i++){
var koko:Point = new Point();
//基準ボタンマウスオーバー時
if(rollover){
if(i == 0){
koko.x = basic_bal.x + 40;
koko.y = basic_bal.y;
}else{
koko.x = arr[i - 1].x + 40;
koko.y = arr[i - 1].y;
}
}
//
else{
if(i == 0){
koko.x = this.stage.stageWidth + 140;
koko.y = this.stage.stageHeight / 2 - 140 - 140;
}else{
koko.x = arr[i - 1].x;
koko.y = arr[i - 1].y;
}
}
arr[i].x += (koko.x - arr[i].x) / 3;
arr[i].y += (koko.y - arr[i].y) / 5;
}
}
}
}
import flash.display.Sprite;
class ball extends Sprite{
public function ball(num:Number){
this.graphics.beginFill(num);
this.graphics.drawCircle(0, 0, 20);
this.graphics.endFill();
}
}