In a recent project, I wanted to load the Unicode values for special
characters from an external XML file. I wanted these values to show up
in a label or text box using something like label.htmlText =
"\ul00A9", which would produce the copyright symbol.  However, when I
loaded the values from a simple XML node, the resulting label showed
the literal value"\ul00A9" instead of the copyright symbol.  I created
a test application and found that local XML vars work and local
Unicode strings work, but not loaded Unicode values from XML. I have
sample URL for my test application (right-click view source) and the 
code below:

URL: http://thanksmister.com/xmlunicode/index.html  

Flex Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="charXML.send();"  height="210"
width="393" viewSourceURL="srcview/index.html">
  <mx:Script>
    <![CDATA[
        private function serviceListener():void
        {
          var tempXML:XMLList =  charXML.lastResult.character as XMLList;
                                
          var localXML:XML = 
                <character>
                <data>\u00A9</data>
                <label>Inverted Exclamation Mark</label>
                </character>;
                                
          test1.htmlText = localXML.data;
          test2.htmlText = "\u00A9";  // string 
          test3.htmlText = tempXML.data;
                                
         }
        ]]>
        </mx:Script>

        <mx:HTTPService 
        url="data/test.xml" 
          id="charXML"
          resultFormat="e4x"            
          result="serviceListener()" />

        <mx:Canvas width="291" height="164" backgroundColor="#ffffff" x="51"
y="19">
          <mx:Label text="Copyright Local XML:" x="10" y="10"/>
          <mx:Label text="" x="201" y="10" id="test1"/>
          <mx:Label text="Copyright Text String:" x="10" y="59"/>
          <mx:Label text="" x="201" y="59" id="test2"/>
          <mx:Label text="Copyright Imported XML:" x="10" y="117"/>
          <mx:Label text="" x="201" y="117" id="test3"/>
        </mx:Canvas>
</mx:Application>


External XML file:

<?xml version="1.0" encoding="UTF-8"?>
<specialChars>
  <character>
    <data>\u00A9</data>
    <label>Copyright sign</label>
  </character>
</specialChars>


Thanks, Michael 






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to