forked from: flash on 2012-9-10
♥0 |
Line 116 |
Modified 2015-09-10 15:46:06 |
MIT License
archived:2017-03-30 10:21:25
ActionScript3 source code
/**
* Copyright jmbyh521 ( http://wonderfl.net/user/jmbyh521 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/CKQA
*/
// forked from Alex.Brown's flash on 2012-9-10
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Rectangle;
import flash.geom.Transform;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
import flash.events.Event;
import flash.text.TextFormatAlign;
import flash.filters.GlowFilter;
[SWF(frameRate = "16", width="1920", height="1080",backgroundColor="0")]
public class Matrixcode extends Sprite {
private var _maxLabel:int = 500;
private var _maxWidth:int = 150;
private var vecText:Vector.<lettre> = new Vector.<lettre>();
private var colorT:ColorTransform;
private var canvas:BitmapData;
private var contLabel:Sprite = new Sprite();
public function Matrixcode()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
this.removeEventListener(Event.ADDED_TO_STAGE, init);
var bg_canvas:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xff000000);
var bg_color:Bitmap = new Bitmap(bg_canvas);
this.addChild(bg_color);
canvas = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00000000);
var glow:GlowFilter = new GlowFilter(0x00c0ff, 1, 8, 8, 2, 1, false, false);
this.contLabel.filters = [glow];
this.addChild(this.contLabel);
var fd:Bitmap = new Bitmap(canvas);
var blur:BlurFilter = new BlurFilter(2, 2, 1);
fd.filters = [blur];
this.addChild(fd);
colorT = new ColorTransform(0.95, 0.992, 1, 0.992, 0, 0, 0, -0.2);
this.addEventListener(Event.ENTER_FRAME, refresh);
}
private function refresh(e:Event):void {
canvas.colorTransform(new Rectangle(0, 0, stage.stageWidth, stage.stageHeight), this.colorT);
for (var i:int = 0; i < this.vecText.length; i++) {
this.refreshLabel(i);
}
if (this.vecText.length < this._maxLabel) {
var label:lettre = new lettre();
label.x = int(Math.random()*this._maxWidth)*(stage.stageWidth/this._maxWidth);
this.contLabel.addChild(label);
this.vecText.push(label);
}
}
private function refreshLabel(i:int):void {
var label:lettre = this.vecText[i];
if (label.y > stage.stageHeight) {
this.contLabel.removeChild(label);
this.vecText.splice(i, 1);
} else {
label.refresh();
}
if ((label.y - label.lastPrint) > (label.textHeight * .5)) {
label.lastPrint = label.y;
this.printLabel(label);
}
}
private function printLabel(label:lettre):void {
var trans:Transform = label.transform;
this.canvas.draw(label,trans.matrix);
}
}
}
import flash.filters.GlowFilter;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormatAlign;
import flash.text.AntiAliasType;
/**
* ...
* @author grafyweb
*/
class lettre extends TextField
{
//[Embed(source = "../matrix code nfi.ttf", fontFamily = "foo", embedAsCFF = 'false')]
// public static const FONT_Matrix:String;
private var allowT:Array = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲンΓΔΘΛΠΣΦΨΩßƂƆƎƐƔÐƷƸƧℲЖИЛШЯѲѪ".split("");
private var vitesse:Number;
public var lastPrint:int = -48;
public function lettre()
{
this.creaLabel();
this.vitesse = 1 + (Math.random() * 16);
}
public function refresh():void {
if ( Math.random() > 0.5 ) this.text = allowT[int(Math.random() * 36) % 36];
else if ( Math.random() > 0.5 ) this.text = allowT[int((36 + (Math.random() * 48)) % 84)];
else if ( Math.random() > 0.5 ) this.text = allowT[int((84 + (Math.random() * 27)) % 111)];
if ( Math.random() > 0.75 ) this.y += this.vitesse;
}
private function creaLabel():void {
var format1:TextFormat = new TextFormat();
format1.font = "Consolas";
format1.color = 0xffffff;
format1.size = 16;
format1.leading = 4;
format1.bold = true;
this.height = 12;
this.width = 12;
this.multiline = false;
this.wordWrap = false;
this.autoSize = TextFieldAutoSize.CENTER;
this.antiAliasType = AntiAliasType.NORMAL;
this.gridFitType = flash.text.GridFitType.PIXEL;
this.defaultTextFormat = format1;
this.text = allowT[ int(Math.random() * allowT.length) % allowT.length ];
}
}