// see: http://www.itmedia.co.jp/news/articles/0905/08/news021.html
// see: http://www.mrc-cbu.cam.ac.uk/people/matt.davis/Cmabrigde/
package {
import flash.display.Sprite;
import flash.text.*;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
private var text:TextField = new TextField();
private var source:String = "こんちには みさなん おんげき ですか ? わしたは げんき です 。 \n "
+ "この ぶんょしう は いりぎす の ケブンッリジ だがいく の けゅきんう の けっか \n "
+ "にんげん は もじ を にしんき する とき \n その さしいょ と さいご の もさじえ あいてっれば \n "
+ "じばんゅん は めくちちゃゃ でも ちんゃと よめる という けゅきんう に もづいとて \n "
+ "わざと もじの じんばゅん を いかれえて あまりす 。\n "
+ "どでうす ? ちんゃと よゃちめう でしょ ? \n "
+ "ちんゃと よためら はのんう よしろく \n\n "
+ "Click to update the document .\n "
+ "クリック すると ぶんしょう を こうしん します 。 \n\n "
+ "Aoccdrnig to rscheearch at Cmabrigde uinervtisy , it deosn 't mttaer waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteres are at the rghit pclae. The rset can be a tatol mses and you can sitll raed it wouthit a porbelm . Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod as a wlohe .\n\n "
+ "A long time ago , so long ago that memories did not exist .\n "
+ "Love was not wide spread among the people \n "
+ "and it was magic or might that ruled the lands .\n "
+ "There were men that set out on precarious adventures \n "
+ "in order to test their strength and courage .\n "
+ "People called these men ... Sorcerian .\n\n ";
public function FlashTest() {
addChild(text);
text.width = 465;
text.autoSize = TextFieldAutoSize.LEFT;
text.wordWrap = true;
Update();
stage.addEventListener(MouseEvent.CLICK, Click);
}
private static function Shuffle(value:String):String {
if (value.length <= 3) return value;
var characters:Vector.<String> = new Vector.<String>();
for (var k:int = 0; k < value.length; k++)
characters.push(value.charAt(k));
var l:int = value.length - 2;
for (var m:int = 0; m < l; m++) {
var i:int = int(Math.random() * l) + 1;
var j:int = int(Math.random() * l) + 1;
var t:String = characters[i];
characters[i] = characters[j];
characters[j] = t;
}
return characters.join('');
}
private function Click(e:MouseEvent):void {
Update();
}
private function Update():void {
text.text = "";
var words:Array = source.split(' ');
for each(var word:String in words) {
text.appendText(Shuffle(word));
text.appendText(" ");
}
}
}
}