Customizing the way XML is transfered into flash file

I am loading an XML document into a flash file.
</slideNode>
  <slideNode jpegURL="images/prizes/prize2.jpg">Prize 2</slideNode>
  <slideNode jpegURL="images/prizes/prize3.jpg">Prize 3</slideNode>
  <slideNode jpegURL="images/prizes/prize4.jpg">Prize 4</slideNode>
  <slideNode jpegURL="images/prizes/prize5.jpg">Prize 5</slideNode>
</Slides>

The text in each record go into a dynamic text field in the fla document. how can I customize the output of the text? Can I put html tages in between the xml tags?
what if I want for example, the word prize to be italicizes and the number to be bold, or something like that?
rivkamakAsked:
Who is Participating?
 
DesignbyonyxConnect With a Mentor Commented:
Make sure that you are embedding the font properly, and make sure you are embedding the bold version of the font as well.

What I usually do is create a dynamic textfield off the stage and I put text in there that has every font I want to use in the movie.  Then in the properties panel I embed the fonts for that text field.  Those fonts are then available for any textfield in my movie (provided I say myTextField.embedFonts = true).

If you use this method for embedding fonts, it is important to put every combination you plan on using (normal, bold, italic).  For example, I usually type in ABC - keep the A normal, make the B bold, and make the C italic.  I do this for every font I want to use in my movie.  

Take care.
~Ryan
0
 
DesignbyonyxCommented:
You can certainly use HTML formatted code in your node values, but they must be encoded:

<i>Prize</i> <b>2</b>

is the html encoding for:

<i>Prize</i> <b>2</b>

You can find tools out there that will encode a string for you:
http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx

You must also enable html (and/or set the htmlText property for the text field)

Let me know if that helps.

~Ryan
0
 
DesignbyonyxCommented:
HaHa, so Expert's Exchange decoded my encoding... probably for security purposes.  Just go to the url I provided and paste the html code from above... you will see the format it needs to be in.  You know it's right when you can't hardly read it.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Aneesh ChopraCommented:
I have better solution:

we can have HTML code in XML without any encoded, it just need to be written using CDATA tag.

here is a working sample with source files:
http://www.4shared.com/account/file/13574307/5d156978/html_data_through_XML.html
0
 
Aneesh ChopraCommented:
here is the link again (in case above link does not work):
http://www.4shared.com/file/13574307/5d156978/html_data_through_XML.html
0
 
rivkamakAuthor Commented:
I'm attaching my code. yet it doesn't show html formatted in my flash file.
http://www.oorah.org/auction/2009/prizes/gallery.html
yet, something must be happening becuase it isn't displaying the tags.

	<description><![CDATA[<p>Sleek, smart and packed with features, this computer package is ideal for home or office. Maximize your efficiency while your donation helps Oorah maximize our children&rsquo;s yeshiva educations, providing support through tutors, homework help and family mentors.</p> <p><strong> DELL COMPUTER:</strong> Quad Core Intel Xeon processor and Windows Vista  offer unmatched speed and ease. Graphics &ldquo;pop&rdquo; on 20&rdquo; inch ultra flat panel screen.<br> <br><strong>DELL LASER PRINTER</strong>: Dell&rsquo;s 5310 is the ideal network printer, handling 50 pages per minute at up to 1200x1200 dpi. Easy to read menus and large LCD display.</p>]]></description>

Open in new window

0
 
Aneesh ChopraCommented:
it also depends how you parse the XML,
you may review code in the sample provided above.

if still not clear,
I suggest to attach your sample source for review and quick fix

0
 
rivkamakAuthor Commented:
When the XML gets transfered into my flash file, my ' get changed into &apos and other & becomes &amp.
How can I program it so that it stays the way I type it?
0
 
DesignbyonyxCommented:
Try escaping those special characters by preceding them with a back slash (\&, \', etc.)
0
 
rivkamakAuthor Commented:
I tried fixing the line with a slash like this  <header>38. Man\'s Wardrobe</header>
and the result i get it this  :38. Man\&apos;s Wardrobe
0
 
rivkamakAuthor Commented:
Also, when I put bold like this: <b>Canon Camera</b>
it boldes the text but adds a , to the begining and end
,Canon Camera'
0
 
DesignbyonyxCommented:
Hmmm.  I have to admit that I have not really done the whole trial and error thing with XML and CDATA, but every time I store html data in an xml file, I store the encoded html (as I mentioned in my first post)... and I have never had any formatting or weird-character issues like you are having.  I wish I could give you the answer you are looking for.  If you send me a zip with your files (or an example scenario with a simple text field, your XML file, and the EXACT code you are using), I'd be glad to take a look at it... it would be a good thing for me to know.

ryan [dot] wheale [at] gmail [dot] com

Please try and make your files work "right out of the box"... meaning I want to be able to open the flash file (or test it on my localhost) and see your problem without having to download any special class files, components, or troubleshooting flaws in your code that don't have anything to do with the matter at hand.  Please include any SQL files if your site uses a database, or MXP files for custom classes or components.  The last guy I helped I had to go to some website and download a tweening class that he used when he could have just included it in the zip he sent me.  Another guy created an "example" file but left out crucial code because he didn't think that the code was relevant.  It just makes things harder on me and it is not a good motivator for helping other people.  (I don't mean to come across as abrasive).  
Thanks.

~Ryan
0
 
DesignbyonyxCommented:
And feel free to use this as a sort of hack, if you want to keep moving forward without waiting for me.  Simply call this function and pass your text to it.
myTextField.htmlText = rebuildHTML( textFromXML );
 
function rebuildHTML(theText:String):String {
   var tempText:String = theText;
 
   tempText = tempText.split("&lt;").join("<");
   tempText = tempText.split("&gt;").join(">");
   tempText = tempText.split("&amp;").join("&");
   tempText = tempText.split("&quot;").join("\"");
 
   return tempText;
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.