Link to home
Start Free TrialLog in
Avatar of Aspirin99
Aspirin99

asked on

How to deal with Apostrophe's from XML import into Flash

I have a dynamic text box that I create with createTextField. It will recieve data from an XML file. If you know the answer to this questions, you know what the apostrophes are doing in my text box. I've tried setting the text box properties to HTML, as you can see below, but it doesn't help.  Is there a solution to this besides editing the XML?

            _root.scrollingTextMc.createTextField("myTitleText", 4, 0, 0, 10, 10);
            _root.scrollingTextMc.myTitleText.type = "dynamic";
            _root.scrollingTextMc.myTitleText.autoSize = true;
            _root.scrollingTextMc.myTitleText.embedFonts = true;
            _root.scrollingTextMc.myTitleText.html = true;
//
      myformat = new TextFormat();
      myformat.color = 0x344139;
      myformat.font = "BankGothic";
      myformat.size = 18;
_root.scrollingTextMc.myTitleText.setTextFormat(myformat);
Avatar of Buffon
Buffon
Flag of Israel image

I used this code:

createTextField("txt_txt", 4, 0, 0, 10, 10);
txt_txt.type = "dynamic";
txt_txt.autoSize = true;

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
     var arr:Array = new Array();
     for (var node:XMLNode = xml.firstChild.firstChild;node != null;node = node.nextSibling)
     {
          arr.push(node.firstChild.firstChild.nodeValue);
     }
    txt_txt.text = arr;
}
xml.load("c:/1.xml");


in my xml there are apostrophes and the textfield looks fine.
Avatar of Aspirin99
Aspirin99

ASKER

That's pretty much the same thing I posted above. So, anyone have an idea of why mine are screwed up?
ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what is the problem with apostrophes :) you just dont want them in textfied?
they break strings in the code

nightmare of note.
Thanks. I am not sure of how to work that into my xml loader. Can you give me a pointer on how to incorporate your code into this?

-----------------------------------------------------
onClipEvent(load) {

// XML Object ------------------------------------------      
_root.songList = new XML();
         _root.songList.ignoreWhite = true;
// --------------- XML ON LOAD -------------------------
_root.songList.onLoad = function(success) {
  if (success) {
// --------------- DEFINE SOUND OBJECTS AND POPULATE LIST COMPONENT--------------
_root.numberOfSongs = _root.songList.firstChild.childNodes.length;
_root.indexSongNumber = _root.numberOfSongs-1;
for (a=0; a < _root.numberOfSongs; a++) {
      _root["song" + a] = new Sound();
      _root["xmlSong" + a]=_root.songList.firstChild.childNodes[a].childNodes[1].childNodes;
      _root["xmlSongTitle" + a]=_root.songList.firstChild.childNodes[a].childNodes[0].childNodes;

// Below is where I populate my list component with the song titles, but the list component does not have a problem with the apostrophes. See the comments further down for the dynamic text box.

      //_root.song_list.addItem(_root["xmlSongTitle" + a]);
}
//---------------------------------------------------------
var nodes:Array = this.firstChild.childNodes;

      for(var i:Number = 0; i < nodes.length; i++){
      var children:Array = nodes[i].childNodes;
_root.song_list.addItem(children[0].firstChild.nodeValue, children);
      }
var listener:Object = new Object();
listener.change = function(evt:Object):Void
                  {
    var data:Object = evt.target.selectedItem.data;

//--------------------- BELOW IS THE PROBLEM BOX ---------------------------------------------------------------------------
// The _root.mySongTitle is the dynamic text box I'm having the problem with.

   _root.mySongTitle = data[0].firstChild;

    _root["song" + _root.nextSong].loadSound(data[1].firstChild, true);
                  }
    _root.song_list.addEventListener("change", listener);
// ------------------ IF XML CAN'T LOAD ----------------------
} else {
      trace("not loaded yet");  
  }
}
// LOAD EXTERNAL XML FILE--------------------------

_root.songList.load("audioPlayer.xml");
      
}// END CLIP EVENT LOAD -------------------------------------------------------------



i assume u got sorted on incorporating it