?
Solved

Customizing the way XML is transfered into flash file

Posted on 2008-11-17
13
Medium Priority
?
737 Views
Last Modified: 2013-11-11
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?
0
Comment
Question by:rivkamak
  • 6
  • 4
  • 3
13 Comments
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 22980866
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
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 22980897
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22982377
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22982393
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
 

Author Comment

by:rivkamak
ID: 22985927
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22986014
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
 
LVL 14

Accepted Solution

by:
Designbyonyx earned 1000 total points
ID: 22986716
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
 

Author Comment

by:rivkamak
ID: 23038633
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
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 23040402
Try escaping those special characters by preceding them with a back slash (\&, \', etc.)
0
 

Author Comment

by:rivkamak
ID: 23044253
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
 

Author Comment

by:rivkamak
ID: 23044284
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
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 23045847
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
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 23046013
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question