ためしに作ったもの
お初にお目にかかります.
AS3を学び始めた初日の産物.Graphics面白い
長方形の描画間隔を1次関数で決めてるから中央付近がきもちわるい
/**
* Copyright 9dim ( http://wonderfl.net/user/9dim )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2JQH
*/
package {
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
/**
* ...
* @author T.H.
*/
public class Main extends Sprite
{
private var sprite : Sprite = new Sprite();
private var graphic : Graphics = sprite.graphics;
private var X : int ;
private var Y : int;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
addChild(sprite);
var timer:Timer = new Timer(1 , 100000000); // 1ミリ秒 = 1回
var split:int = 0;
timer.addEventListener(TimerEvent.TIMER, timerFunc);
timer.start();
function timerFunc(event:TimerEvent):void
{
graphic.clear();
//背景の描画
graphic.beginFill(0x000000, 1);
graphic.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphic.lineStyle (1, 0x00FF00, 1.0); // 直線スタイルを設定
for (var i : int = 0; i < 9; i++) { //消失線の描画
graphic.moveTo (0, stage.stageHeight/9*i);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth, stage.stageHeight/9*i);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth/9*i,0);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth/9*i, stage.stageHeight);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
}
graphic.beginFill(0x00FF00, 0);//塗りつぶしの設定
for (var i : int = 0; i < 20; i++) { //奥行き感の表現
/*
X = stage.stageWidth * Math.pow(i, 1 / 2) / 4;
Y = stage.stageHeight * Math.pow(i, 1 / 2) / 4;
graphic.drawRect(X/2,Y/2,stage.stageWidth-X,stage.stageHeight-Y);
*/
X = stage.stageWidth * i / 20 - split;
Y = stage.stageHeight * i / 20 - split;
if (X < 0) {
X = stage.stageWidth - split;
Y = stage.stageHeight - split;
}
graphic.drawRect(X / 2, Y / 2, stage.stageWidth - X, stage.stageHeight - Y);
}
if (split++ == 40) { split = 0; }
}
}
}
}