In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Text Layout Framework Hello, World

////////////////////////////////////////////////////
Flash Text Egine による Text Layout Frameworkのサンプル
author: Motoki Matsumoto
email: mtmotoki(at)gmail.com
///////////////////////////////////////////////////
Get Adobe Flash player
by mtok 27 Jan 2009
    Embed
//////////////////////////////////////////////////////
// Flash Text Egine による Text Layout Frameworkのサンプル
// 
// author: Motoki Matsumoto
// email: mtmotoki(at)gmail.com
/////////////////////////////////////////////////////
package  
{
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.display.LoaderInfo;
	import flash.system.LoaderContext;
	import flash.system.ApplicationDomain;
	import flash.system.SecurityDomain;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author ...
	 */
	public class HelloWorld extends Sprite
	{
		
		public function HelloWorld() 
		{
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
		}
		
		private function addedToStage(e:Event):void 
		{
			var l:Loader = new Loader();
			var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);
			l.load(new URLRequest("http://www.matzmtok.com/wonderfl/lib/TextLayoutLib.swf"), context);
			l.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
		}
		
		private function completeHandler(e:Event):void 
		{
			var li:LoaderInfo = e.target as LoaderInfo;
			
			var domain:ApplicationDomain = li.content.loaderInfo.applicationDomain;
			
			var TextFlow:Class = domain.getDefinition("flashx.textLayout.elements.TextFlow") as Class;
			var ParagraphElement:Class = domain.getDefinition("flashx.textLayout.elements.ParagraphElement")as Class;
			var SpanElement:Class = domain.getDefinition("flashx.textLayout.elements.SpanElement")as Class;
			var DisplayObjectContainerController:Class = domain.getDefinition("flashx.textLayout.container.DisplayObjectContainerController") as Class;
			
			var textFlow:* = new TextFlow();
			var p:* = new ParagraphElement();
			textFlow.addChild(p);
			
			var span:* = new SpanElement();
			span.text = "Hello, World";
			span.fontSize = 48;
			p.addChild(span);
			
			textFlow.flowComposer.addController(new DisplayObjectContainerController(this, 400, 200));
			textFlow.flowComposer.updateAllContainers();
		}
		
	}
	
}