質問

I'm having a problem with the TLFTextField where I can't seem to get superscript to work. What the code is supposed to do is load in another swf file, go through each of the display objects, and if it finds a TLFTextField with an id that matches, replace the dot with the tag that should turn the cents to superscript. I'm able to change the font size of the cents after the period if i use a font tag, but i need it to change the baseline of the text. I've looked all over and haven't found anything that works for superscript yet. Is there something wrong with the way i'm trying to turn the text to superscript?

dispObjArray = findChildrenByName(root, "price_id_" + key);
if (dispObjArray)
{
    for (var tlf:int=0;tlf<dispObjArray.length;tlf++)
    {                           
        if (dispObjArray[tlf] is TLFTextField) {        

            var supBegin:String = "<span baselineShift='superscript'>";
            var supEnd:String = "</span>";

            var sup:String = pricesDict[key].@Price;
            sup = sup.replace(".", supBegin) + supEnd;

            try { (dispObjArray[tlf] as TLFTextField).htmlText = sup; } catch (e:*) { trace(e); }
        }
    }
}

By the way, i've noticed that the span tag seems to get removed after i set the htmlText

役に立ちましたか?

解決

so to get the baseline shift working, you have to add

<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p>

in front of the text, and close it with

</p></TextFlow>

So for example, with what i might work with, it would look like:

<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p>9<span baselineShift='superscript'>00</span></p></TextFlow>

to get a regular 9, and a superscript 00.

my final code looks like this:

dispObjArray = findChildrenByName(root, "price_id_" + key);
if (dispObjArray)
{
    for (var tlf:int=0;tlf<dispObjArray.length;tlf++)
    {                           
        if (dispObjArray[tlf] is TLFTextField) {        

            var sBegin:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p>"
            var supBegin:String = "<span baselineShift='superscript'>";
            var supEnd:String = "</span>";
            var sEnd:String = "</p></TextFlow>";
            var sup:String = pricesDict[key].@Price;
            sup = sBegin + sup.replace(".", supBegin) + supEnd + sEnd;

            try { (dispObjArray[tlf] as TLFTextField).tlfMarkup = sup; } catch (e:*) { trace(e); }
        }
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top