SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML character encoding via an XML file... import to CS3/AS3

    I have an XML doc in which I'm using to import text to Flash CS3 -- using AS3.

    What needs to be done to encode a character? My text might need an ">>" which is raquo U+00BB (187) -- do you have to embed a font or something?

    Using CDATA in my XML produces absolutely nothing, not even for <b> or <i>. So I'm not sure why that doesn't work either...

    Any help is appreciated.

  2. #2
    RTFM ashleyk's Avatar
    Join Date
    Dec 2005
    Location
    Rochester, New York
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look up the entity here:

    http://www1.tip.nl/~t876506/EntitiesXHTML1.html

    you'd have to be more clear about how you are importing the text and how you are displaying it to get more help.
    ---------------------------------------
    Ashley Kennedy
    ---------------------------------------
    how does a designer get roped into writing code?

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you'd have to be more clear about how you are importing the text and how you are displaying it to get more help.
    well... to keep it simple then -- say my goal was simply to extract information about some music albums and display that text within one dynamic text field.

    Code:
    Meat Beat Manifesto
    Satyricon
    1992
    Mute
    ----------------------------
    Next album...
    ----------------------------
    All good until an album with a plus sign (plus may be a bad example but go with me on it):

    HTML Code:
    Meat Beat Manifesto
    Actual Sounds + Voices
    1998
    Nothing
    Is there not a general, easy method for incorporating the plus sign entity -- any entity for that matter? In the code below, since I'm just extracting the data from XML, it seems I could do something in the XML file to make this work...

    Code:
    function LoadAlbumXML(event:Event):void 
    	{
    		var albumContent:XML = new XML(event.target.data);
    		extractAlbumData(albumContent);
    	}
    	
    function extractAlbumData(albumData:XML) 
    	{	
    		var albumTextBox = parentMC.albumTextBox;
                    albumTextBox.htmlText = albumData;
            }
    My XML file just has the album info... nothing else like a header or -- anything at top. Is that why CDATA isn't working (the CDATA code in my file is right by example).

    If I can clarify any of this again please let me know.

    Thx.

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not complaining just can't believe this isn't something easily done

  5. #5
    RTFM ashleyk's Avatar
    Join Date
    Dec 2005
    Location
    Rochester, New York
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here's a simple example. you will see that flash can read the entity either way you put it into the xml doc...

    you will notice in the fla i have embedded the needed characters to display the text (actually for this demo you would only need the Latin I set of characters because that is the set that contains the >> character you require.)

    my guess is that either:
    A) you aren't embedding any fonts, but the device font your computer is using as a substitute doesn't contain the needed character.

    B) you are embedding the font but not including the characters you need

    C) you are embedding, but the font you are embedding doesn't contain the character you need.

    you didn't include any information about the textfield you are displaying text in, the fonts you are using, etc.....so can't really comment on it. The example i've included uses Arial, which contains pretty much any character you need, so if you were to turn the embedding off it would still render the characters correctly.
    Attached Files Attached Files
    ---------------------------------------
    Ashley Kennedy
    ---------------------------------------
    how does a designer get roped into writing code?

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for putting together this example ashleyk, it helps a great deal.

  7. #7
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been trying to do the same thing for several hours and wasn't using the right command in Flash!!!

    I was using just .text instead of .htmlText .... thanks to your demo file I am not going to lose my mind after all!


Bookmarks

Posting Permissions

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