flash on 2011-12-8
♥0 |
Line 62 |
Modified 2011-12-08 20:33:54 |
MIT License
archived:2017-03-20 14:56:40
ActionScript3 source code
/**
* Copyright 3f5 ( http://wonderfl.net/user/3f5 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/in8M
*/
package {
import flash.utils.Timer;
import flash.display.Sprite;
public class UnkoTest extends Sprite {
public var timer:Timer = new Timer(1000);
public function UnkoTest() {
var size:Number = 15;
var x:int, y:int, half:int = 645 / size, unko:Unko;
timer.start();
for (y = 0; y < half; y++) {
for (x = 0; x < half; x++) {
unko = new Unko(size);
unko.x = size * x;
unko.y = size * y;
addChild(unko);
}
}
}
}
}
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.Event;
class Unko extends Sprite {
private const e:Number = 0.5;
private var size:Number;
public function Unko(_size:Number) {
super();
size = _size;
graphics.beginFill(0xFF0000);
graphics.drawRect(0, 0, size, size);
graphics.endFill();
//alpha = 0;
addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void {
call(0.8);
});
}
public function call(count:Number):void {
if (count < 0) return;
this.alpha = count;
var unko:Unko, p:UnkoTest = parent as UnkoTest;
for (var i:uint = 0; i < parent.numChildren; i++) {
unko = p.getChildAt(i) as Unko;
if ((unko.x == x && unko.y == y - size) || (unko.x == x && unko.y == y + size)
|| (unko.x == x + size && unko.y == y) || (unko.x == x - size && unko.y == y)
|| (unko.x == x + size && unko.y == y + size) || (unko.x == x - size && unko.y == y - size)
|| (unko.x == x - size && unko.y == y + size) || (unko.x == x + size && unko.y == y - size)) {
p.timer.addEventListener(TimerEvent.TIMER, function ():void {
unko.call(Number((count - e).toFixed(1)));
p.timer.removeEventListener(TimerEvent.TIMER, arguments.callee);
});
}
}
p.timer.addEventListener(TimerEvent.TIMER, function ():void {
Wonderfl.log('ウンコのクサさ is ' + (count).toString());
alpha = 1;
p.timer.removeEventListener(TimerEvent.TIMER, arguments.callee);
});
}
}