<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:components="org.tinytlf.components.*"
               xmlns:local="*"
               xmlns:spark="org.tinytlf.components.spark.*"
               width="600"
               height="600"
               minWidth="600"
               minHeight="600"
               creationComplete="onCreationComplete()" viewSourceURL="srcview/index.html">
    <fx:Script>
        <![CDATA[
            import org.tinytlf.ITextEngine;
            import org.tinytlf.components.spark.RichTextField;
            import org.tinytlf.interaction.TanyaAnchorMirror;
            import org.tinytlf.layout.factories.HTMLDivAdapter;
            import org.tinytlf.layout.factories.HTMLTableAdapter;
            
            [Embed("assets/fonts/calibri.ttf", fontFamily="Calibri")]
            private var calibri:Class;
            [Embed("assets/fonts/calibrib.ttf", fontFamily="Calibri", fontWeight="bold")]
            private var calibriBold:Class;
            [Embed("assets/fonts/calibrii.ttf", fontFamily="Calibri", fontStyle="italic")]
            private var calibriItalic:Class;
            [Embed("assets/fonts/calibriz.ttf", fontFamily="Calibri", fontWeight="bold", fontStyle="italic")]
            private var calibriBoldItalic:Class;
            
            [Embed("assets/wikipedia.css", mimeType="application/octet-stream")]
            private const cssSource:Class;
            
            [Embed("assets/testText.html", mimeType="application/octet-stream")]
            private const xmlSource:Class;
            
            private function onCreationComplete():void
            {
                var engine:ITextEngine = biggieSmalls.engine;
                engine.layout.textBlockFactory.mapElementFactory("div", HTMLDivAdapter);
                engine.layout.textBlockFactory.mapElementFactory("table", HTMLTableAdapter);
                engine.interactor.mapMirror("a", TanyaAnchorMirror);
                
                biggieSmalls.style = new cssSource().toString();
                biggieSmalls.text = new xmlSource().toString();
            }
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout horizontalAlign="center"/>
    </s:layout>

    <s:Scroller id="scroller" width="550" height="600">
        <spark:RichTextField id="biggieSmalls" width="100%"/>
    </s:Scroller>


</s:Application>