TextParticle
...
@author DefaultUser (Tools -> Custom Arguments...)
// write as3 code here..
package
{
import flash.display.MovieClip;
import flash.events.*;
/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class TxtParticle extends MovieClip {
public function TxtParticle () {
stage.frameRate = 40;
addEventListener(Event.ENTER_FRAME, func1);
}
public function func1(event:Event):void {
var mc:TxtObj = new TxtObj(mouseX, mouseY, Math.random() * 11 - 6, Math.random() * -10, Math.random() * 0.5 + 0.3, Math.random() * 10 - 5);
addChildAt(mc, 0);
}
}
}
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.filters.*;
import flash.geom.ColorTransform;
import flash.events.*;
import flash.text.*;
import flash.display.Sprite;
class TxtObj extends MovieClip {
var posx:Number;
var posy:Number;
var velx:Number;
var vely:Number;
var grav:Number;
var rot:Number;
var fillnum:Number;
var fill:BlurFilter;
public function TxtObj(num1:Number,num2:Number,num3:Number,num4:Number,num5:Number,num6:Number) {
posx = num1;
posy = num2;
velx = num3;
vely = num4;
grav = num5;
rot = num6;
fillnum = 0;
fill = new BlurFilter(0, 0);
var obj:Txt = new Txt();
addChild(obj);
x = posx;
y = posy;
//filters = [fill];
rotation = Math.random() * 360;
scaleX = scaleY = Math.random() * 2.0 + 0.3;
addEventListener(Event.ENTER_FRAME, func2);
}
public function func2(event:Event):void {
vely += grav;
posx += velx;
posy += vely;
x = posx;
y = posy;
rotation += rot;
fillnum += 0.1;
fill = new BlurFilter(fillnum, fillnum);
//filters = [fill];
if (x < 0 || x > stage.stageWidth || y > stage.stageHeight) {
removeEventListener(Event.ENTER_FRAME, func2);
parent.removeChild(this);
}
}
}
class Txt extends MovieClip {
public function Txt() {
var coltxt:String = "23456789abcdef";
var tx:String = coltxt.charAt(Math.random()*coltxt.length);
var num:uint = uint("0x" + tx + tx + tx + tx + tx + tx);
var txt:TextField = new TextField();
var format:TextFormat = new TextFormat();
var sizenum:int = Math.random() * 10 + 10;
format.align = TextFormatAlign.LEFT;
format.font = "Verdana";
format.color = num;
format.size = sizenum;
format.bold = true;
//txt.embedFonts = true;
txt.defaultTextFormat = format;
var selectTxt:String = "死滅虐殺害姦淫叫呪犯罪屍屠";
var selected:String = selectTxt.charAt(Math.random() * selectTxt.length);
txt.text = selected;
txt.selectable = false;
var txtmc:MovieClip = new MovieClip();
txtmc.addChild(txt);
var tempBt:BitmapData = new BitmapData(txtmc.width, txtmc.height, true, 0x00000000);
tempBt.draw(txtmc);
var dispmc:MovieClip = new MovieClip();
dispmc.addChild(new Bitmap(tempBt, "auto", true));
addChild(dispmc);
dispmc.x -= sizenum / 2;
dispmc.y -= sizenum / 2;
}
}