text-shuffle 練習です。
text-shuffle 一度やってみたかったので
http://hato-style.chu.jp/note/rnd_text.html参考に
作成させていただきました。少しづつ解読したいです。
♥0 |
Line 69 |
Modified 2010-06-11 03:52:15 |
MIT License
archived:2017-03-20 02:46:14
ActionScript3 source code
/**
* Copyright plus-tic ( http://wonderfl.net/user/plus-tic )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eDq7
*/
/*text-shuffle 一度やってみたかったので
http://hato-style.chu.jp/note/rnd_text.html参考に
作成させていただきました。少しづつ解読したいです。*/
package{
import flash.display.MovieClip;
import flash.text.TextField;
public class index extends MovieClip {
private var tf:TextField;
private var tf1:TextField;
public function index():void {
var rt:randomText;
tf = new TextField();
tf.x = 50;
tf.y = 50;
tf.text = 'text-shuffle';
addChild(tf);
tf1 = new TextField();
tf1.x = 150;
tf1.y = 50;
tf1.text = "shigenokai";
addChild(tf1);
rt = new randomText(tf);//ここに対応するTextFieldを引数として渡す
rt.start();
rt = new randomText(tf1);
rt.start();
}
}
}
import flash.display.DisplayObjectContainer;
import flash.text.TextField;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
class randomText{
private var defaultTxt:String;
private var searchTxt:String = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?#$%&/+-=;_:'
private var tt:TextField;
private var compTxt:String = '';
private var nowLen:uint = 0;
private var Interval:uint = 10;
private var Change:uint = 10;
private var time:Timer;
public function randomText(t:TextField):void{
defaultTxt = t.text;
tt = t;
tt.text = '';
}
public function start():void{
time = new Timer(Interval,Change);
time.addEventListener(TimerEvent.TIMER,randomText_search);
time.addEventListener(TimerEvent.TIMER_COMPLETE,randomTextComp);
time.start();
}
public function stop():void{
time.stop();
time.removeEventListener(TimerEvent.TIMER,randomText_search);
time.removeEventListener(TimerEvent.TIMER_COMPLETE,randomTextComp);
}
private function randomText_search(e:Event):void{
tt.text = compTxt + searchTxt.charAt(Math.floor(Math.random()*searchTxt.length));
}
private function randomTextComp(e:Event):void{
compTxt = compTxt + defaultTxt.charAt(nowLen);
tt.text = compTxt;
if(nowLen <= defaultTxt.length - 2 ){
++nowLen;
start();
}else{
stop();
}
}
}