flash on 2011-10-2

by fujiopera
♥0 | Line 30 | Modified 2011-10-02 19:31:14 | MIT License
play

ActionScript3 source code

/**
 * Copyright fujiopera ( http://wonderfl.net/user/fujiopera )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hcYR
 */

package {
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.geom.Rectangle;
  import flash.net.*;
  
  import flashx.textLayout.factory.StringTextLineFactory;
  import flashx.textLayout.formats.TextAlign;
  import flashx.textLayout.formats.TextJustify;
  import flashx.textLayout.formats.TextLayoutFormat;

  public class ch18ex3 extends Sprite {
    public function ch18ex3() {
      var loader:URLLoader = new URLLoader(new URLRequest(
        "http://actionscriptbible.com/files/alice-ch1.txt"));
      loader.addEventListener(Event.COMPLETE, onLoadComplete);
    }
    protected function onLoadComplete(event:Event):void {
      var controller:StringTextLineFactory = new StringTextLineFactory();
      controller.text = URLLoader(event.target).data;
      controller.compositionBounds = 
        new Rectangle(5, 5, stage.stageWidth-10, stage.stageHeight-10);
      var format:TextLayoutFormat = new TextLayoutFormat();
      format.fontFamily = "Book Antiqua, Garamond, _serif";
      format.fontSize = 13;
      format.columnCount = 3;
      format.columnGap = 15;
      controller.textFlowFormat = format;
      controller.createTextLines(addChild);
    }
  }
}