棒グラフ的な
/**
* Copyright littlepad ( http://wonderfl.net/user/littlepad )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mgdv
*/
// forked from littlepad's 折れ線グラフ的な
package {
import flash.display.Sprite;
import caurina.transitions.Tweener;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
init();
}
private function init():void {
var unit:Number = 15; // グラフ間隔
var defaultY:Number = 400; // 基準Y座標
// グラフデータ
var data:Array = [ 5, 40, 55, 80, 82, 90, 98, 101, 120, 140, 145, 156, 160, 166, 170, 172, 173, 176, 190, 210, 205, 212, 220, 223, 240, 244, 258, 269, 270 ];
// 背景
var background:Background = new Background(defaultY, unit);
addChild(background);
for( var i:uint = 0; i < data.length; i++ ) {
var bar:Bar = new Bar( unit * (i + 1), defaultY, unit );
bar.alpha = 0;
addChild(bar);
Tweener.addTween( bar, { alpha:1, delay:0.08 * i });
Tweener.addTween( bar, { height:data[i], time:0.5, delay:0.08 * i, transition:"easeoutCirc" } )
}
}
}
}
import flash.display.Sprite;
internal class Bar extends Sprite {
public function Bar(posX:Number, posY:Number, unit:Number) {
x = posX;
y = posY;
graphics.beginFill(0xFFFFFF * Math.random());
graphics.drawRect(0, -1, unit, 1);
graphics.endFill();
}
}
import flash.display.Sprite;
internal class Background extends Sprite {
public function Background(posY:Number, unit:Number) {
var numX:Number = Math.floor(465 / unit);
for( var i:uint = 0; i < numX; i++ ){
graphics.lineStyle(1, 0x0000FF, 0.1);
graphics.moveTo(unit * i, posY);
graphics.lineTo(unit * i, 0);
graphics.endFill();
}
var numY:Number = Math.floor(400 / unit);
for( var j:uint = 0; j < numY; j++ ){
graphics.lineStyle(1, 0x0000FF, 0.1);
graphics.moveTo(0, posY - unit * j);
graphics.lineTo(465, posY - unit * j);
graphics.endFill();
}
}
}