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.crea teTextFiel d("myTitle Text", 4, 0, 0, 10, 10);
_root.scrollingTextMc.myTi tleText.ty pe = "dynamic";
_root.scrollingTextMc.myTi tleText.au toSize = true;
_root.scrollingTextMc.myTi tleText.em bedFonts = true;
_root.scrollingTextMc.myTi tleText.ht ml = true;
//
myformat = new TextFormat();
myformat.color = 0x344139;
myformat.font = "BankGothic";
myformat.size = 18;
_root.scrollingTextMc.myTi tleText.se tTextForma t(myformat );
_root.scrollingTextMc.crea
_root.scrollingTextMc.myTi
_root.scrollingTextMc.myTi
_root.scrollingTextMc.myTi
_root.scrollingTextMc.myTi
//
myformat = new TextFormat();
myformat.color = 0x344139;
myformat.font = "BankGothic";
myformat.size = 18;
_root.scrollingTextMc.myTi
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what is the problem with apostrophes :) you just dont want them in textfied?
they break strings in the code
nightmare of note.
nightmare of note.
ASKER
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.firstChi ld.childNo des[a].chi ldNodes[1] .childNode s;
_root["xmlSongTitle" + a]=_root.songList.firstChi ld.childNo des[a].chi ldNodes[0] .childNode s;
// 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["xml SongTitle" + 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(ch ildren[0]. firstChild .nodeValue , children);
}
var listener:Object = new Object();
listener.change = function(evt:Object):Void
{
var data:Object = evt.target.selectedItem.da ta;
//--------------------- 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].fi rstChild, true);
}
_root.song_list.addEventLi stener("ch ange", listener);
// ------------------ IF XML CAN'T LOAD ----------------------
} else {
trace("not loaded yet");
}
}
// LOAD EXTERNAL XML FILE---------------------- ----
_root.songList.load("audio Player.xml ");
}// END CLIP EVENT LOAD -------------------------- ---------- ---------- ---------- -----
--------------------------
onClipEvent(load) {
// XML Object --------------------------
_root.songList = new XML();
_root.songList.ignoreWhite
// --------------- XML ON LOAD -------------------------
_root.songList.onLoad = function(success) {
if (success) {
// --------------- DEFINE SOUND OBJECTS AND POPULATE LIST COMPONENT--------------
_root.numberOfSongs = _root.songList.firstChild.
_root.indexSongNumber = _root.numberOfSongs-1;
for (a=0; a < _root.numberOfSongs; a++) {
_root["song" + a] = new Sound();
_root["xmlSong" + a]=_root.songList.firstChi
_root["xmlSongTitle" + a]=_root.songList.firstChi
// 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(
}
//------------------------
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(ch
}
var listener:Object = new Object();
listener.change = function(evt:Object):Void
{
var data:Object = evt.target.selectedItem.da
//--------------------- 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(
}
_root.song_list.addEventLi
// ------------------ IF XML CAN'T LOAD ----------------------
} else {
trace("not loaded yet");
}
}
// LOAD EXTERNAL XML FILE----------------------
_root.songList.load("audio
}// END CLIP EVENT LOAD --------------------------
i assume u got sorted on incorporating it
createTextField("txt_txt",
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;
{
arr.push(node.firstChild.f
}
txt_txt.text = arr;
}
xml.load("c:/1.xml");
in my xml there are apostrophes and the textfield looks fine.