package {
import com.adobe.viewsource.ViewSource;
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
[SWF (backgroundColor='#ffffff', width='800', height='600')]
public class TLFSample04 extends Sprite {
public function TLFSample04() {
super();
ViewSource.addMenuItem(this, "srcview/index.html");
const MARK_UP:String =
"<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
"<div><p>Hello, World!!</p></div>" +
"<p>My name is <span fontSize='25'>Taiga.</span></p><p>I'm from Japan.</p>" +
"</TextFlow>";
var textFlow :TextFlow = new TextFlow();
var target :MySprite = addChild( new MySprite() ) as MySprite;
var gap :int = 10;
var controllerWidth_ :int = 410;
var controllerHeight_ :int = 200;
var width_ :int = controllerWidth_ + gap + gap;
var height_ :int = controllerHeight_ + gap + gap;
var g :Graphics = target.getGraphics();
textFlow = TextConverter.importToFlow(MARK_UP, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.interactionManager = new EditManager( new UndoManager() );
textFlow.flowComposer.addController(
new ContainerController(target, controllerWidth_, controllerHeight_)
);
textFlow.columnCount = 3;
textFlow.columnGap = 10;
textFlow.backgroundAlpha = 1;
textFlow.backgroundColor = 0xff9900;
textFlow.flowComposer.updateAllControllers();
target.x = target.y = 100;
g.beginFill(0xcccccc);
g.drawRect(-gap, -gap, width_, height_);
g.endFill();
g.beginFill(0xdddddd);
g.drawRect(0, 0, 130, 200);
g.endFill();
g.beginFill(0xdddddd);
g.drawRect(140, 0, 130, 200);
g.endFill();
g.beginFill(0xdddddd);
g.drawRect(280, 0, 130, 200);
g.endFill();
}
}
}
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.geom.Rectangle;
class MySprite extends Sprite {
protected var dummyShape:Shape;
public function MySprite() {
super();
dummyShape = new Shape();
}
public override function addChild(child:DisplayObject):DisplayObject {
trace("MySprite.addChild()");
return super.addChild(child);
}
public override function removeChild(child:DisplayObject):DisplayObject {
trace("MySprite.removeChild()");
return super.removeChild(child);
}
public override function get graphics():Graphics {
trace("MySprite.graphics");
return dummyShape.graphics;
}
public override function set scrollRect(value:Rectangle):void {
trace("scrollRect : ", value);
}
public function getGraphics():Graphics {
return super.graphics;
}
}