forked from: code on 2008-12-18
HelloFlag
@author final hiroshi
// forked from final_hiroshi's code on 2008-12-18
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.GradientType;
import flash.filters.DisplacementMapFilter;
import flash.events.Event;
import flash.geom.Point;
import flash.text.TextField;
import flash.text.TextFormat;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="15")]
/**
* HelloFlag
* @author final hiroshi
*/
public class HelloFlag extends Sprite{
public function HelloFlag() {
var flag:Sprite = new Sprite();
flag.graphics.beginFill(0x00000000);
flag.graphics.drawRect(30, 30, 400, 300);
addChild(flag);
var pole:Sprite = new Sprite();
pole.graphics.beginFill(0x999999);
pole.graphics.drawRect(30, 30, 10, 400);
addChild(pole);
var tf:TextField = new TextField();
tf.text = "你好世界!!"
tf.autoSize = "left";
tf.setTextFormat(new TextFormat("黑体", 48, 0xFFFFFF));
tf.x = 30 + (400 - tf.width) / 2;
tf.y = 30 + (300 - tf.height) / 2;
flag.addChild(tf);
var bmpd:BitmapData = new BitmapData(flag.width, flag.height);
var v:Number = 0;
stage.addEventListener(Event.ENTER_FRAME, function():void {
bmpd.perlinNoise(bmpd.width, bmpd.height, 2, 5, false, true, 7, false, [new Point(v, 0), new Point(v, 0)]);
flag.filters = [new DisplacementMapFilter(bmpd, new Point(0, 0), 1, 1, 30, 30, "color")];
v += 20;
});
}
}
}