DoTextFormatTweener:Progression Command を使ったTextFormatのモーション作り
♥2 |
Line 91 |
Modified 2009-06-26 14:17:32 |
MIT License
archived:2017-03-10 15:30:02
ActionScript3 source code
/**
* Copyright quqjp ( http://wonderfl.net/user/quqjp )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/h009
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
import org.libspark.thread.Thread;
import org.libspark.thread.EnterFrameThreadExecutor;
[SWF(width = "465", height = "465", backgroundColor = "0xFFFFFF", frameRate = "40")]
public class FlashTest extends Sprite {
public function FlashTest() {
if (!Thread.isReady) {
Thread.initialize(new EnterFrameThreadExecutor());
}
var myTf:TextField = new TextField()
myTf.width = 465;
myTf.height = 465;
myTf.text = "quq.jp DoTextFormatTweener Class "
+ "quq.jp DoTextFormatTweener Class "
+ "quq.jp DoTextFormatTweener Class"
+ "quq.jp DoTextFormatTweener Class"
+ "quq.jp DoTextFormatTweener Class"
+ "quq.jp DoTextFormatTweener Class"
+ "quq.jp DoTextFormatTweener Class"
+ "quq.jp DoTextFormatTweener Class"
myTf.wordWrap = true;
this.addChild(myTf);
//DoTextFormatTweener Command 動作テストThreadの実行
var oTextThread:TextThread = new TextThread(myTf);
oTextThread.start();
}
}
}
import flash.text.TextField;
import flash.text.TextFormat;
import jp.progression.core.commands.Command;
import caurina.transitions.Tweener;
import org.libspark.thread.Thread
import org.libspark.thread.threads.progression.CommandThread;
/*
* TextFormatをTweenerさせるCommand Class
* letterSpacing、leading などのモーション作りにつかえます。
*/
class DoTextFormatTweener extends Command {
private var oTextField:TextField;
private var initObject:Object;
private var tweenerparamaters:Object;
private var myTextFormat:TextFormat;
public function DoTextFormatTweener( tf:TextField,tweenerparamaters:Object) {
this.oTextField = tf;
this.tweenerparamaters = tweenerparamaters;
super( _execute, _interrupt, initObject );
}
private function _execute():void {
tweenerparamaters.onComplete = executeComplete;
tweenerparamaters.onUpdate = onUpdate;
myTextFormat = oTextField.getTextFormat();
Tweener.addTween(myTextFormat,tweenerparamaters)
}
private function onUpdate():void {
oTextField.setTextFormat(myTextFormat)
}
private function _interrupt():void {
interruptComplete();
}
}
/*
* 動作テスト用Thread Class
*/
class TextThread extends Thread
{
private var myTf:TextField;
public function TextThread(param:TextField) {
myTf = param
};
protected override function run():void
{
next(doExecute);
}
protected override function finalize():void
{
}
private function doExecute():void {
//letterSpacingとleadingを15にモーションさせます
var oDoTextFormatTweener:DoTextFormatTweener = new DoTextFormatTweener(myTf,
{letterSpacing:15, leading :15,time:2}
)
var oCommandThread:CommandThread = new CommandThread(oDoTextFormatTweener);
oCommandThread.start();
oCommandThread.join();
next(clear);
}
private function clear():void {
var oDoTextFormatTweener:DoTextFormatTweener = new DoTextFormatTweener(myTf,
{letterSpacing:0, leading :2,time:2}
)
var oCommandThread:CommandThread = new CommandThread(oDoTextFormatTweener);
oCommandThread.start();
oCommandThread.join();
next(doExecute);
}
}