flash on 2014-10-21
♥0 |
Line 45 |
Modified 2014-12-04 15:54:30 |
MIT License
archived:2017-03-20 11:42:23
ActionScript3 source code
/**
* Copyright hemingway ( http://wonderfl.net/user/hemingway )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/n7XU
*/
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(frameRate=60, width=465, height=465)]
public class Main extends Sprite {
private var _canvas:Bitmap;
private var _canvasData:BitmapData;
private var _particleVec5:Vector.<int>;
public function Main() {
this._canvasData = new BitmapData(465, 465, false, 0xDCDCDC);
this._canvas = new Bitmap(this._canvasData);
this._particleVec5 = new Vector.<int>(7, true);
this._particleVec5[0] = 1; //x
this._particleVec5[1] = 1; //y
this._particleVec5[2] = 1; //vX
this._particleVec5[3] = 1; //vY
this._particleVec5[4] = 15; //tX
this._particleVec5[5] = 15; //tY
this._particleVec5[6] = 0; //§col
this.addEventListener(Event.ADDED_TO_STAGE, this.addedToStageHandler);
}
private function addedToStageHandler($event:Event):void {
this.removeEventListener(Event.ADDED_TO_STAGE, this.addedToStageHandler);
this.addChild(this._canvas);
this.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
this.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.stage_mouseDownHandler);
this.stage.addEventListener(MouseEvent.MOUSE_UP, this.stage_mouseUpHandler);
}
private function stage_mouseDownHandler($event:MouseEvent):void {
(this._particleVec5[5] == 15) ? this._particleVec5[3]+=20: this._particleVec5[3];
}
private function stage_mouseUpHandler($event:MouseEvent):void {
}
private function enterFrameHandler($event:Event):void {
(this._particleVec5[1]+this._particleVec5[3] > 465 || this._particleVec5[1]+this._particleVec5[3] < 0) ? this._particleVec5[3] = (~this._particleVec5[3] + 1) : this._particleVec5[1] += this._particleVec5[3];
(this._particleVec5[0]+this._particleVec5[2] > 465 || this._particleVec5[0]+this._particleVec5[2] < 0) ? this._particleVec5[2] = (~this._particleVec5[2] + 1) : this._particleVec5[0] += this._particleVec5[2];
this._particleVec5[5] = (this._particleVec5[1]+this._particleVec5[3] >= 465) ? ((this._particleVec5[5] == 1) ? 15 : this._particleVec5[5]-1) : this._particleVec5[5];
this._particleVec5[3] = (this._particleVec5[3] < this._particleVec5[5]) ? this._particleVec5[3]+1 : this._particleVec5[3];
this._canvasData.setPixel32(this._particleVec5[0], this._particleVec5[1], this._particleVec5[4]);
}
}
}