forked from: 美
@author jc at bk-zen.com
/**
* Copyright q.kensuke ( http://wonderfl.net/user/q.kensuke )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/l81P
*/
// forked from bkzen's 美
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.engine.EastAsianJustifier;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
import flash.text.engine.FontLookup;
import flash.text.engine.FontPosture;
import flash.text.engine.FontWeight;
import flash.text.engine.LineJustification;
import flash.text.engine.RenderingMode;
import flash.text.engine.TextBlock;
import flash.text.engine.TextElement;
import flash.text.engine.TextLine;
import flash.text.engine.TextRotation;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
/**
*
* @author jc at bk-zen.com
*/
[SWF (backgroundColor = "0xFFFFFF", frameRate = "30", width = "465", height = "465")]
public class Beautifl extends Sprite
{
private var txtBox:Sprite;
private var arr:Array;
public function Beautifl()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e: Event = null): void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//
txtBox = createTextBlock();
txtBox.x = stage.stageWidth / 2;
txtBox.y = stage.stageHeight / 2;
txtBox.scaleX = txtBox.scaleY = 10;
addChild(txtBox);
var tw: ITween = BetweenAS3.serial(
BetweenAS3.delay(
BetweenAS3.to(txtBox, { scaleX: 0.5, scaleY: 0.5, rotation: 180}, 5), 2
), BetweenAS3.to(txtBox, { y: -50 }, 4)
);
tw.onComplete = start;
tw.play();
}
private function start(): void
{
arr = [];
var i: uint = 0;
for (i = 0; i < 100; i++)
{
var sp: Sprite = createTextBlock();
sp.x = Math.random() * 465, sp.y = -10;
sp.rotation = 180;
addChild(sp);
BetweenAS3.repeat(BetweenAS3.delay(BetweenAS3.to(
sp, {y: 480}, Math.random() * 7 +3
), Math.random() * 10), 100).play();
arr[i] = sp;
}
}
private function createTextBlock(): Sprite
{
var font: FontDescription = new FontDescription(
"メイリオ,ヒラギノ角ゴ Pro W3,MS Pゴシック,_ゴシック,_等幅",
FontWeight.BOLD, FontPosture.NORMAL, FontLookup.DEVICE, RenderingMode.NORMAL
);
var format: ElementFormat = new ElementFormat(font, 24, 0x333333);
format.locale = "ja";
var textBlock: TextBlock = new TextBlock();
textBlock.lineRotation = TextRotation.ROTATE_0;
textBlock.textJustifier = new EastAsianJustifier("ja", LineJustification.UNJUSTIFIED);
textBlock.content = new TextElement("楽", format);
var sp: Sprite = new Sprite();
var txtLine: TextLine = textBlock.createTextLine();
txtLine.x = - txtLine.width / 2;
txtLine.y = txtLine.height / 2;
sp.addChild(txtLine);
sp.scaleX = sp.scaleY = 0.5;
return sp;
}
}
}