A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Html text not diaplaying properly via xml

  1. #1

    Html text not diaplaying properly via xml

    I need to laod some text from an external xml file which contain some htnl formatting. I got the following file below and the text is not diaplying very well, any text after an html tag will get cut off. Any idea how to solve this?

    www.dreamance.com/download/demo.zip

    Thank
    chup

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    XML will interpret the BR tag as an XML tag, therefore, the XML is invalid because the BR has no closing tag!

    There are two ways around this problem, one is easier if you are generating the text using ASP or similar, and the other is easier if you are using a text editor. Both work, but the first way is both valid and flexible while the second way is a bit of a cheat.

    1. Encoding the HTML tags: For the HTML, replace all the < and > with &amp;gt; and &amp;lt; ... .nodeValue will return the HTML properly so you don't have to reconvert at the Flash end.

    2. Cheating: Only use matching tags (P and /P for new line, B and /B etc. in your HTML. You then send the entire node (not the nodeValue property) to the htmlText property of your text file.

  3. #3
    Hi AlsoGaiusCoffey

    Thanks for th fast reply. But i couldn't understand what you explain, can your provided more explanation or an example?

    Thanks

    Chup

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Try putting some CDATA tags into your XML.

    http://www.w3schools.com/xml/xml_cdata.asp

  5. #5
    Hi rdoyle720,

    Thanks for the reply too, but i'm really rather new to xml. Can where should i place the CDATA thingy?

    chup

  6. #6
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    This shows all three methods. Thanks rDoyle for that, I have never bothered with CData before as the ASP XML object does it all for you ...

  7. #7
    Hi AlsoGaiusCoffey,

    Thanks for the files, they are sure useful

    I've been following the part on CDATA, but it still doesn;t work for me. Did i go wrong anywhere?

    Here the source file i'm working on


    Thanks again!
    Chup
    Attached Files Attached Files

  8. #8
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Sorry, I can't open MX 04 files. The XML looks OK though.
    It looks from the SWF as if you are setting the text property and not the htmlText property of the textfield.

  9. #9
    Hi AlsoGaiusCoffey, yes you are right, i forgot to turn the textfield to an html field. I thought that by setting them to .htmlText will solve the problem.. haha

    There one more issius i found out, embed text. If we embed an pixel font, the rest of the bold and italic text won't be displaying. But we we dun embed the font, system without thr font will display the text incorrectly, what sld we do?

    Chup

  10. #10
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    If you don't embed the font, Flash will try to use the nearest match it finds on the computer of the person running the movie. This means you have to allow for a certain amount of size variation.

    You can embed a font for all of the different styles by:
    1. Going to the library and clicking on the top right and selecting "New Font"
    2. Selecting the font you want and adding it to the library
    3. Repeating step 2 for all the formats you use with the font (bold, bold italic, italic)
    4. Setting linkage for the fonts to be exported in the first frame

    Obviously, this will make your file quite big...

  11. #11
    AlsoGaiusCoffey, Thanks for all the help.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center