Frage

IM ÜBERBLICK
Ich habe eine Flash-Anwendung (gemacht für Flash Lite - Actionscript 2). Wenn ich lade in meiner Anwendung eine XML Datei und ich verarbeiten es in einem Objekt. Ich erhalte die richtige HTML-Eingabe in einem Textfeld.
Allerdings, wenn ich hard das Objekt , alle HTML-Tags aus dem .htmlText Attribute verschwinden und es gibt Code vor dem Text platziert. Es ist meine Absicht, das Objekt zu codieren, da der Laden schnell viel geht dann xml.

Kurz und gut: string.html = true; löscht alle span-Tags, während ich diese benötigen. Wie erhalte ich die span-Tags in der html meines Textfeldes?

MEHR INFO UNTER

In meiner Anwendung haben ich erstellen Textfelder Text in ihnen und legen Sie den richtigen x- und y-Wert, so dass sie alle gut unter ihnen gesetzt werden.

in der Funktion:

//ABOVE I CREATE TEXTFIELD USING THE .CREATETEXTFIELD FUNCTION
this["text" + this._textFieldCounter].html = true;
this["text" + this._textFieldCounter].multiline = true;
this["text" + this._textFieldCounter].wordWrap = true;
this["text" + this._textFieldCounter].autoSize = true;
this["text" + this._textFieldCounter].styleSheet = this._styleSheet;
this["text" + this._textFieldCounter].condenseWhite = true;
this["text" + this._textFieldCounter].htmlText = "<span class=\"page\">" + strHtmlText + "</span>";
//trace(this["text" + this._textFieldCounter].htmlText);

Wenn ich die htmlSpuren ich

<P ALIGN="LEFT">
<FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">
//here comes the strHtmlText
</FONT>
</P>

Flash-automatisch diejenigen p und font-Tag vor meinem Text setzen. So wird mein Sheet zeigt nicht den richtigen Stil. Wie kann ich von der anfänglichen align und font-Tag loszuwerden, aber immer noch das Textfeld halten als html?

Bearbeiten
Durch die Einrichtung eines Textformat Ich habe einen Weg, um dieses Problem gefunden ... JEDOCH
Ich habe ein neues Problem:
In meinem strHtmlText gibt es Span-Tags (<span class="text-in">blabla</span>), aber das wird herausgefiltert. Warum ist das ? mein Sheet tut nichts ohne diese Stile.

(Text wird aus einem Array geladen)

War es hilfreich?

Lösung

It must have something to do with the order in which you assign the properties to the TextField. It should be: 1. set field.html to true, 2. assign styleSheet, 3. set htmlText. The styleSheet must be set before the htmlText is assigned - I originally posted a link to the as3 documentation, but this is true for both AS2 and AS3.

Try this: Put a TextField on the stage of a new AS2 FLA. Set its type to dynamic. Name it to "_textField". Set the font to Verdana, 16px, Black. Enter "Error." or something similar into the TextField, so that it has some text in it. Click "Embed fonts", be sure to include a sufficient amount of letters, like ascii or Latin-1. On the timeline, enter this code into the first frame of the Movie.

var style:TextField.StyleSheet = new TextField.StyleSheet();
style.parseCSS("p {font-family:Verdana; font-size:12px; color:#FF0000;}");
_textField.html = true;
_textField.styleSheet = style
_textField.htmlText = "<p>This is a test.</p>";
trace (" new text:"+_textField.htmlText);

Now when you run the program, it should change the text to "This is a test", the color to red and the font size to 12 px. It does on my computer. Also, the trace prints the exact same text that is assigned to htmlText.

Now go back and exchange the lines assigning the styleSheet and htmlText properties. Re-run the program. It will have all the extra tags you were complaining about.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top