package { import flash.display.Sprite; import flash.display.StageScaleMode; import flash.text.TextField; import flash.text.TextFormat; import org.tinytlf.ITextEngine; import org.tinytlf.components.TextField; [SWF("500", height="200")] public class HallmanTest extends Sprite { // [Embed(source="assets/fonts/Interstate Regular.ttf", fontName="Interstate", fontWeight="Regular", embedAsCFF="true", mimeType="application/x-font")] // private var interstateFont:Class; // // [Embed(source="assets/fonts/Interstate Regular.ttf", fontName="Interstate", fontWeight="Regular", embedAsCFF="false", mimeType="application/x-font")] // private var interstateFontNoCFF:Class; public function HallmanTest() { super(); stage.scaleMode = StageScaleMode.NO_SCALE; var tf:org.tinytlf.components.TextField = new org.tinytlf.components.TextField(); var engine:ITextEngine = tf.engine; // engine.interactor.mapMirror("a", H1Interactor); var html:String = '<p>RT <a>@destroytoday</a>: Canon has been hav' + 'ing fun: <a>http://j.mp/a5q6os</a> <a>http://j.mp/acmqKJ</a>' + ' <a>http://j.mp/bggftX</a> <a>http://j.mp/dkv0PF</a> <a>http' + '://j.mp/d0JSH2</a></p>'; tf.y = 20; tf.width = 250; // tf.engine.styler.setStyle("selectionColor", 0x007998); // tf.engine.styler.setStyle("selectionAlpha", .85); tf.style = "*{fontName: Interstate; fontSize: 11; color: 0xBBBBBB; lineHeight: 3; " + "renderingMode: normal; cffHinting: horizontalStem; selectionColor:0x007998; selectionAlpha: 0.2;}" + "h1{cursor:button;}" + "a{color: 0x007998;cursor:hand;}" + "a:hover{ color: 0x3CADAE;}" + "a:active{color: 0x007998;}" + "a:visited{underline: false;}"; tf.text = "<body>" + html + "</body>"; addChild(tf); var field:flash.text.TextField = new flash.text.TextField(); field.defaultTextFormat = new TextFormat('Interstate', 11, 0xBBBBBB); field.embedFonts = true; field.htmlText = html; field.width = 250; field.height = 180; field.x = 250; field.y = 20; field.wordWrap = true; field.multiline = true; addChild(field); } } } //import flash.events.MouseEvent; //import flash.events.TextEvent; //import flash.net.URLRequest; //import flash.net.navigateToURL; // //import org.tinytlf.interaction.CSSInteractor; //import org.tinytlf.interaction.EventLineInfo; //import org.tinytlf.util.TinytlfUtil; //import org.tinytlf.util.XMLUtil; // //class H1Interactor extends CSSInteractor //{ // override protected function onMouseUp(event:MouseEvent):void // { // var info:EventLineInfo = EventLineInfo.getInfo(event, this); // if (!info) // return; // // var tree:Array = (info.element.userData as Array); // if (!tree || !tree.length) // return; // // trace(info.engine.layout.containers[0].measuredHeight); // var link:Object = XMLUtil.buildKeyValueAttributes(tree.concat().pop().attributes()); // var href:String = link['href']; // //// if (TinytlfUtil.isBitSet(mouseState, DOWN)) //// { // //If there's an href, launch the URL. Otherwise, dispatch an event from this TextLine. // if (href) // { // trace(href); // navigateToURL(new URLRequest(href), link['target'] || '_blank'); // } // else // { // trace(info.element.text); // info.line.dispatchEvent(new TextEvent(TextEvent.LINK, true, false, info.element.text)); // } //// } // // super.onMouseUp(event); // } //}