Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




MX2004: XPathAPI CDATA SelectSingleNode And HTML Formatting



Hello,my subject is pretty much my problem, i am using MX2004's XPathApi 'selectSingleNode' which is working nicely, i have done a wee bit of fiddling;
Code:
_root.selectedText = "About Us "centreMe.textContent.htmlText = mx.xpath.XPathAPI.selectSingleNode(this.firstChild, "/data/item[@name = '"+ _root.selectedText + "']/*");
I would like to be able to change the content depending on what the variable is, and this seems to work fine. The content should be formatted text (with <p> etc...), so i am using CDATA tags to make sure no confusion is made with <>'s (and if i dont it only pulls in a small section - as expected). Only problem is that for some reason it forgets it is a html formatted bit of CDATA and spits out the <p> tags with the rest of the content... i have placed in "centreMe.textContent.html = true;" make sure it knows its html but it really doesnt want to know.I tried using selectNodeList to an array and printing this - which works, without CDATA tags, but adds a really annoying "," at the end of each "array item" it is printing.Any help would be fantastic as i have also been through an entire saga to get here trying different techniques to get html tags displaying correctly within CDATA - and i guess this is ultimately my problem?Thanks for your time!Løque--------edit > now i am having a really "noobie" problem (if my one above wasnt already enough)this works;
Code:
bla.html = true;bla.htmlText = "this is frustrating?";
but this doesnt display anything in my dynamic textbox;
Code:
bla.html = true;bla.htmlText = "<b> this is frustrating?</b>";
why does actionscript hate me? its player 7 with as2



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 10-11-2005, 04:50 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

XML And CDATA Not Formatting As HTML Text
Last edited by yakken : 2007-12-16 at 20:37.
























I have a site that uses XML to load text, pics etc. but I have a problem using the CDATA tag in my XML files and afterwards rendering the text as HTML.

The XML could be

HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<events>
<event pic="largePicture.png" header="Headline" caption="Subheadline" smallpic="thumbnail.png">
<description>
<![CDATA[<b>I would like to use HTML here</b><br>Next line!]]>
</description>
</event>
</events>
Loading the XML works fine and I have everything saved in arrays (the text I need here, would be in the "descriptions" array - see below), that I can access, but when I try to throw my the <description> content into a textbox, it displays everything as it is typed above - including the tags etc. I would be setting up the text like this (taken out of context and boiled down a bit to make it easy on the eye):

ActionScript Code:
//this is the i'th element that I am loading
["mc_text"+i].descrip.html=true;
["mc_text"+i].descrip.multiline = true;
["mc_text"+i].descrip.autoSize = true;
["mc_text"+i].descrip.htmlText= descriptions[i];

where the "decrip" text field would be the one containing my text.

It does, however, not format my text as HTML (the autosize attribute works though). A direct link to one of the subpages, not showing my text properly is here: http://www.vanity.dk/oceanclub/test.swf
Pres the last button on the right...

Help is appreciated!

I can see that this guy seems to have the same troubles as I:
HTML Links in xml.
but none of the suggestions in that thread seems to do the trick

Cdata Formatting?
I'm using CDATA tags in XML to pass Flash html formatted text. Unfortunately using CDATA makes Flash take the text very literally (preserves line breaks, tabs, etc, etc) so I have to format the HTML as one long line. Is there a way to use CDATA to pass html formatted text and yet have it ignore line breaks, etc as a browser would with HTML? Perhaps even somehow removing those extra characters after it's loaded into Flash?

CDATA - Still Not Formatting
Ok. I have searched the forum up and down and read about 6 different ways to supposedly add formatting to text through XML but nothing is working.

I have tried CDATA, I have tried URL encoding, and I have tried HTML encoding of '<''s and '>''s but still no luck. When I use CDATA around a block of text with a <b></b> in it, it will just show the <b> instead of parsing it.
I have html enabled on the text box. Did it through actionscript and then with the gui. I also tried embedding the font.
In dreamweaver it appears that the first <b> tag is closing the CDATA tag.

Here's my XML:


Code:
<![CDATA[TORONTO - A vegetarian diet high in fibre and low in saturated fats can lower cholesterol levels as effectively as some drugs, according to a new Canadian study. The study suggests some people should forgo medication in favour of the diet to control their cholesterol.

Researchers from the University of Toronto followed 46 people in the study. The participants averaged 59 years of age, all had high blood pressure and were overweight. They were split into three groups: one group followed a special diet, dubbed the Portfolio Diet, designed by the scientists; others followed a diet low in saturated fats (beef, butter) and used the cholesterol-lowering drug lovastatin; the last group ate a low-fat diet but didn't take the drug.

<b>Sample Diet <b>
Snack: Almonds, fruit, soy beverage
Dinner: Tofu bake with eggplant, onions and peppers, vegetables and pearled barley

Those on the Portfolio Diet ate foods with a lot of viscous fibre such as barley, oatmeal, okra and eggplant. The diet is based on one created by Dr. David Jenkins, known for his Garden of Eden diet plan of berries and roots. This time, Jenkins' team decided to make the diet more varied and to test the results. "This diet has got the right sort of mix of tolerability and effectiveness to suit a number of people," said Jenkins.

The team discovered:
* Those on the Portfolio Diet saw a 28.6 per cent reduction in their LDL (low-density lipoprotein) cholesterol levels just after one month;
* Those on the low fat diet with the drug achieved a 30.9 per cent reduction over the same period;
* Those just eating a low fat diet saw an eight per cent reduction.

LDL cholesterol is responsible for the fat layers that build up inside the walls of blood vessels causing hardening of the arteries and heart disease.

Researchers say there's little difference between the two groups and conclude that their diet has the same effect as the drug.

The study is published in the Journal of the American Medical Association.]]>
Is there any way short of creating a function to read the string and somehow replace the <b>Sample Diet</b> with <b>+"Sample Diet"+</b> ?

CDATA Xml Formatting
this is my xml row and i wish to apply html formatting to info parameter at the end of line.

<marker name="Amar Yatri Niwas" address="Tourist Complex Area, Fatehabad Road," address2="Agra - 282001, Uttar Pradesh, INDIA" lat="27.160835" lng="78.033607" id="2" thumbpath="" type="hotel" category="3 Star Hotel" web="www.hotelamar.com" info="test2" />

TO

info="<b>test</b> <a href="test.htm">i am online</a>"

can anyone tell me how would i do that ?
i know CDATA but i tried all the way and it didnt worked so i hope someone could help me here.

plz urgent help needed.

[mx2004] Text Formatting
here my code, it doesn't apply wither the color nor the font format..don't know why..please help


ActionScript Code:
test.htmlText = true;
test.html = true;
myFormat = new TextFormat();
myFormat.font = "Oggle";
myFormat.color = 0xff0000;
test.setTextFormat(myFormat);
txt = "<b>Project name :</b> gsdfds" + newline + "g34t224g";
test.text = txt;


thanks for your help

XML CDATA - Formating HTML
Hi there my load of xml goes okay but all html styles as... strong.. color
and image dont work

what am I doing wrong


AS:
-------------------------------------------------------------------------
var mydata:XML = new XML("data.xml")
mydata.ignoreWhite = true;
mydata.onLoad = function(success:Boolean) {
cont = mydata.firstChild.firstChild.childNodes
tmptxt = mydata.firstChild.firstChild.childNodes
cont2=tmp.text
};

cnt_txt.html = true;
mydata.load("data.xml")

-------------------------------------------------------------------------

XML

<?xml version="1.0" encoding="utf-8" ?>
<content>
<txt><![CDATA<div><img alt="" src="../Uploads/flashtest/dv-cam.jpg" border="0" /> This is <strong>BOLD and this <span style="COLOR: #ff0000">red</span></strong></div>]]></txt>
</content>

CDATA Problem With HTML
Hello all.

I am pulling a XML node in with CDATA and html tages, e.g.
<fill><![CDATA[<font color='#FFFF00'>Recruitment: apply locally work globally</font></fill>

for some reason when i trace my var it looks :
<font color=&apos;#FFFF00&apos;>Recruitment: apply locally work globally</font>

and is literally writing out the html instead of displaying it within the textfield.
My textfield is set to html and I am using .htmlText.

Any ideas?

Xml CDATA Formating Html
Hi there my load of xml goes okay but all html styles as... strong.. color
and image dont work

what am I doing wrong


AS:
-------------------------------------------------------------------------
var mydata:XML = new XML("data.xml")
mydata.ignoreWhite = true;
mydata.onLoad = function(success:Boolean) {
cont = mydata.firstChild.firstChild.childNodes
tmptxt = mydata.firstChild.firstChild.childNodes
cont2=tmp.text
};

cnt_txt.html = true;
mydata.load("data.xml")

-------------------------------------------------------------------------

XML

<?xml version="1.0" encoding="utf-8" ?>
<content>
<txt><![CDATA<div><img alt="" src="../Uploads/flashtest/dv-cam.jpg" border="0" /> This is <strong>BOLD and this <span style="COLOR: #ff0000">red</span></strong></div>]]></txt>
</content>

Html In XML...CDATA Not Working.
Hey everyone. I'm trying to do a player roster for a sports team. I used the VERY helpful grid gallery I found on here as a template (THANK YOU). However, I'm having a bit of an issue. I want to be able to format the xml using html in the xml file itself...for example I'd like to be able to insert pictures, make text bold, etc. using html tags in my dynamic text field. I enabled the "render as html" button thing. When I put


Code:
<caption><![CDATA[<font size="14">this is a <b>TEST</b></font>]]></caption>
in my xml, i just get: <font size="14">this is a <b>TEST</b></font> in my caption box. What am I doing wrong?

HTML In Cdata Issue
I am trying to load an xml file into a flash movie with CDATA in it and my text is coming out as disassembled html markup. Here is an example of my xml file with the nodes being supplied by form fields running tinyMCE.


Code:
<?xml version="1.0" encoding="UTF-8"?>
<specialsInfo>
<sunday><![CDATA[<p>Sunday</p>]]></sunday>
<monday><![CDATA[<p>Monday</p>]]></monday>
<tuesday><![CDATA[<p>Tuesday</p>]]></tuesday>
<wednesday><![CDATA[<p>Wednesday</p>]]></wednesday>
<thursday><![CDATA[<p>Thursday</p>]]></thursday>
<friday><![CDATA[<p>Friday</p>]]></friday>
<saturday><![CDATA[<p>Saturday</p>]]></saturday>
</specialsInfo>
and it comes out like the following

<p>Thursday<p>

If I follow the thread below

http://www.sitepoint.com/forums/show...ead+html+cdata

and write the following code into my AS file


Code:
specialtxt.html = true;
specialtxt.htmlText = totalDays[today].childNodes;
specialtxt.html = true;
specialtxt.htmlText = specialtxt.text;
it seems to work fine but I was hoping someone could shed some light on the reason why this my be doing this and how I might correct it without what seems to be a work around.

Thanks in advance

Cdata And Html Tags Not Displaying From XML
After searching high and low for solution, found the following:

<caption2><![CDATA[<font color=blue>"Called to Serve"</font>]]></caption2>

and thought all was well till i tried it....dont work.

The actual characters are displayed. Have text being rendered as HTML tried it without it. tried using escape characters instead of <> etc.

Any thoughts or snipets that have worked?....confused...lost.

CDATA To Pass HTML Via XML Into Flash
My apologies if this has already been answered, but its driving my up the wall how HARD it still is for flash to even import data. It's amazingly annoying trying to convert data into XML and than be readble by flash, why can't macromedia be 'normal' and have some connector that can directly connect to a SQL database, how annoying!!

Anyway enough about my rant...

I have a WYSIWYG html editor on my website that generates flash readable HTML code and we use PHP to store the information that is generated as a .xml file to be readable by our flash file. The data is passed via XML but trying to get the HTML tags through without the XML parser thinking its XML and interfering, and I've managed to research find the CDATA tag to pass information in (please note, i dont know much XML, just basics to get it to work) but it doesn;t work!!

When I try to HTML code that is wrapped in the CDATA than it just shows as "null" on my flash file, but if i remove the CDATA tag and put in simple text it seems to work ok! even if i put in


Code:
<b>you better work, damn you!</b> this part is not bold, but doesnt show anyway
than the part in bold shows as bold but anything after that has disappeared

Any ideas how I can effeciently put HTML into flash and get flash to successfully render it as HTML?!? Please note I've already used a .txt file unsucessfully and it seems to have LOTS of issues with special characters

Any working examples? Can i get source code?

Textfield Not Rendering Html In CDATA... ?
I'm using CDATA to display text in a textfield that has "render text as html" selected, but it's not rendering the html tags within the CDATA.

here's the xml code:

Code:
<pic>
<image>images/01_img.jpg</image>
<description title="Title 1" price="$$$$$">
<![CDATA[2007, acrylic on canvas,<br>20" x 40"</br>]]>
</description>
<thumbnail>thumbs/01_thb.jpg</thumbnail>
</pic>
I'm not 100% sure that my AS is correct for the path to the CDATA. I have this...

legend.txtLegend.facts.text = description[p].firstChild.nodeValue;

Could someone possibly point out why the html tags are not being rendered and also tell me if the path I have to the CDATA is correct. It works, but I wanted to make sure it was correct.

thanks for the help.

CDATA Issue With HTML Text
Hello,
I have an htmlTextField that I am loading html text from a xml doc. the problem is that the text is not rendering as html. so all my HTML is displayed in the textField.

here is the XML:

Code:
<description><![CDATA[<b>Recipe</b> for a tremendously ... ]]></description>
here is the AS:

Code:
myDescription.htmlText = pageDescription[m];
but if i do this:

Code:
myDescription.htmlText = "<b>Recipe</b> for a tremendously ... ";
the html displays correct. so I know that the textField is setup to display the html. when I trace pageDescription I get:

Code:
<b>Recipe</b> for a tremendously ...
I'm not sure how to fix this. Can anyone help me? thanks.

CDATA Html Being Skipped In Output
I've a basic gallery type project that has three dynamic text fields pulling from an xml file. One of the fields needs to be able to output html style type - fairly basic stuff - bold, italic, a few accented characters. When I output, the text appears for everything BUT the stuff in the html tags.

Trying to get this project that the client had held off on for some time into action early this week.

Here's the link to the stuff archive of everything in the project.

http://easternentertaining.com/chefs/chefs.sit

I'm sure I've missed something in the AS - just confusing myself now on calling that node. All help appreciated.

Thanks,
Donna

XML And CDATA Showing HTML Tags
Hi all,

I am hopeful someone can recommend a solution to my dilemma.  Here is what I have...

I am building a simple Flash tutorial with an XML file, two movie clips that act as "Next" & "Previous" buttons and a textbox placeholder for content from the XML file.  I am using <![CDATA[...]]> in the XML so I can format the content with HTML tags.  

My XML looks something like this...

<lesson>
    <screen audio="scriptclip1.mp3" artwork="image1.jpg">
    <![CDATA[<b>Lesson 1</b> text goes here]]>
    </screen>
    <screen audio="scriptclip2.mp3" artwork="image2.jpg">
    <![CDATA[Lesson 2 text goes here]]>
    </screen>
    <screen audio="scriptclip3.mp3" artwork="movie.swf">
    <![CDATA[Lesson 3 text goes here]]>
    </screen>
</lesson>

The functionality of the tutorial works just fine, however, the text formatting is rendering the HTML tags.  I am stumped about how to code this properly and it is highly possible I am missing something simple.  I have also spent quite abit of time in this forum and others reading what I could about the use of XML and CDATA, but couldn't quite get my actionscript to work.

Here is what the script looks like:

drawScreen = function(){
    info_txt.text = lessonList[currentScreen];
    info_txt.background = true;
    info_txt.border = true;
    info_txt.borderColor = 0xC0C0C0;
    
    if (currentScreen == 0){
        prev_mc._visible = false;    
    }else{
        prev_mc._visible = true;    
    }
    if (currentScreen == lessonList.length-1){
        next_mc._visible = false;    
    }else{
        next_mc._visible = true;    
    }    
}
next_mc.onRelease = function(){
    stopAllSounds();
    ++currentScreen;
    drawScreen();
}
prev_mc.onRelease = function(){
    stopAllSounds();
    --currentScreen;
    drawScreen();
}
currentScreen = 0;
lessonList = new Array();
lesson_xml = new XML();
lesson_xml.ignoreWhite = true;
lesson_xml.onLoad = function(){
    var screenNode = this.firstChild.firstChild;
    var audioClip = this.firstChild.firstChild.attributes.audio;
    while (screenNode != null){
        lessonList.push(screenNode.firstChild.nodeValue);
        screenNode = screenNode.nextSibling;
        soundHolder = new Sound();
        soundHolder.loadSound(audioClip);
        soundHolder.start(0);
    }
drawScreen();
    }
lesson_xml.load("lesson.xml");

Any ideas anyone?

Thanks,

websh

Render XML CDATA To HTML In Text Field?
I know I'm probably missing something simple, but I can't for the life of me get the following to render as HTML in flash.

Actionscript:


Code:
content_txt.html = true;
topicNavXml = new XML();
topicNavXml.ignoreWhite = true;
topicNavXml.load("pageBuildNav.xml");
topicNavXml.onLoad = function() {
pageInfo =
topicNavXml.firstChild.childNodes[0].childNodes[0].firstChild;
content_txt.htmlText = pageInfo;
};
XML:


Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <topicNavigation>
<topicPages>

<page><![CDATA[<p><font><b>General</b></font></p><p><font>Here is some text</p><p></p><p>In here is more text</font></p>]]></page>
</topicPages>
</topicNavigation>

What I get is the native format displaying in content_txt as follows:

<p><font><b>General</b></font></p><p><font>Here is some text</p><p></p><p>In here is more text</font></p>

I'd like this to be rendered as HTML in the content_txt field.


Any ideas?

Thanks!

Html Formattig With CDATA When NodeValue Shows XML?
Hi all!

I've been looking around the forums and this question seems to have been asked 100 times before. I think I have a slight twist on it though...

I am loading an xml document into Flash (exporting for player v6, AS1) and want HTML formatting in my dynamic HTML text fields. I've got CDATA there and using eg childNodes[i].chldNodes the text renders the tags and everything. If i use childNodes[i].nodeValue, the text field remains empty.

When I trace the nodeValue is comes out as 'null' and the nodeType is shown to be type 1 - element_node.

So the (for me) 1 000 000 000 kronor question is: am i missing something that defines a text node?

Here's an extract from the XML:


Code:
<page>
<name>Arbetsskada</name>
<avtalText>Som arbetsgivare är du skyldig att göra en anmälan till försäkringskassan.</avtalText>
<header>På blanketterna till försäkringskassan och till AFA ska du som arbetsgivare endast intyga anställningsförhållandena, inte bedöma om det föreligger

arbetsskada, eller ej. Utredningen och ställningstagandet görs av försäkringskassan och AFA men underlättas av din redogörelse. </header>
<pic>arbetsskada.jpg</pic>
<contents>
<subHead>
<name>Den skadade anmäler</name>
<cont><![CDATA[Den skadade ska anmäla arbetsskadan till:
<li>Arbetsgivaren</li>
<li>AFA - på blankett aLink2</li>]]></cont>
<pic>skadAnmal.jpg</pic>
</subHead>
<subHead>
<name>Arbetsgivaren anmäler</name>
<cont>Som arbetsgivare ska du:
- Anmäla arbetsskadan till försäkringskassan. Försäkringskassan tillhandahåller blankett, du hittar den också här: aLink1.
- Du ska också komplettera blanketten aLink2, som den anställde fyllt i, med hans/hennes anställningsuppgifter och sedan underteckna den. Den ska sedan skickas till

AFA. </cont>
<pic>arbGiv2Sub.jpg</pic>
</subHead>
</contents>
</page>
All wise words greatly appreciated!

samiam

XML Content In CDATA Not Ready HTML Tags
I have HTML tags in my XML content file, but need to wrap CDATA around it to prevent illegal characters from doing wrong stuff.

My XML node looks like this:
<pageintro><![CDATA[First paragraph of page content.<br />Second paragraph of <b>Page</b><i>content</i>]]></pageintro>

in my XML actionscript I parse the node like this:
intro_txt.htmlText = content_xml.firstChild.childNodes[i].firstChild;

and in my actionscrip I have also specified
intro_txt.html = true;

the intro_txt textfield has the html button ticked as well.

BUT it is not reading the html tags for some reason. It is just displaying them as characters so <br /> is not a line break it is written out like so: "<br />"

Any idea what I am missing in order for the html tags to be parsed properly?

Cdata W/html Tags Not Displaying Correctly [mx]
Hi,

i am having an annoying problem with an xml document and flash.

i have a dynamic textfield on the stage and this is set to render html.

in the xml doc i have a child node that is wrapped around cdata (as in the kirupa tut). No matter what i do, i can't get flash to correctly parse and display the text.

i.e.

in the xml:



<![CDATA[<b>make this bold</b>]]>



so in flash i get this in the text field:
<b>make this bold</b>

tried it with different tags, and read all sorts of forums including this:
http://www.kirupa.com/forum/showthre...a+dynamic+text

all i really want to do is hav line breaks in my block of text (i have some bulleted points and then a paragraph of text).

any help is really appreciated.

thanx

Embedding HTML In XML Using CDATA Problem (urgent)
Can someone help me please with this, i'm having MAJOR issues, I'll post the code for my actionscript and my XML. Everything looks like it should work, but I still see the HTML tags in my text boxes when I play the movie. Need this ASAP. I'm just trying to get the first node figured out using this test sample. Need immidiate help, please.

Appreciate it

Actionscript

Code:
myTextField.html = true;
var myXMLObject:XML = new XML();
myXMLObject.ignoreWhite = true;
myXMLObject.load("myData.xml");
myXMLObject.onLoad = function() {
var myText:XMLNode = myXMLObject.childNodes[0];
if (myText.nodeName == "navigation") {
for (var count = 0; count<myText.childNodes.length; count++) {
var currentNode:XMLNode = myText.childNodes[count];
set("text_"+(count+1), currentNode.childNodes[0].nodeValue);
set("title_"+(count+1), currentNode.attributes.Title);
myTextField.text = text_1;
myTitleText.text = title_1;
}
}
};
stop();
XML:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<navigation>
<myText Title="News"><![CDATA[Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sodales, <b>ante in tincidunt gravida</b>, est ante lacinia nisl, sit amet rutrum nibh tellus a dui. Etiam tellus <b>lorem</b>, facilisis luctus, aliquam et, molestie ac, libero. Curabitur purus. In nec mi. Nulla elit. Suspendisse sagittis lectus sit amet nisl. <b>Vestibulum aliquet</b> tellus eget metus. In posuere neque. Praesent placerat. Maecenas libero. Donec scelerisque convallis metus.]]> </myText>
<myText Title="BIOGRAPHY">Biography</myText>
<myText Title="Media">This is where Media will go.</myText>
<myText Title="Photos">This is where Photos will go.</myText>
<myText Title="Tours">This is where Tours will go.</myText>
<myText Title="Community">This is where a Link to the boards will go.</myText>
<myText Title="Links">This is where Links will go.</myText>
</navigation>

Cdata W/html Tags Not Displaying Correctly [mx]
Hi,

i am having an annoying problem with an xml document and flash.

i have a dynamic textfield on the stage and this is set to render html.

in the xml doc i have a child node that is wrapped around cdata (as in the kirupa tut). No matter what i do, i can't get flash to correctly parse and display the text.

i.e.

in the xml:



<![CDATA[<b>make this bold</b>]]>



so in flash i get this in the text field:
<b>make this bold</b>

tried it with different tags, and read all sorts of forums including this:
http://www.kirupa.com/forum/showthre...a+dynamic+text

all i really want to do is hav line breaks in my block of text (i have some bulleted points and then a paragraph of text).

any help is really appreciated.

thanx

Parsing Html Embed In Xml Cdata Tags
Hello:

I'm dealing with an XML document, that has embed an html document, it looks like this:

<node>
<![CDATA[<b>SOME BOLDED TEXT</b>]>
</node>

the problem is that when I parse de xml document, what I found is something like

<b> some bolded text </b>

so, when I try to embed this into a textarea component, or a textfield, it shows the <>, instead of the formated HTML code.

Does any body has a clue of whats missing here? I have seen posts over the internet, where people said they have just done it, but none explains how.

Thanks in advance.

Mark

XML - <[CDATA[ Enclosed HTML Tags Appearing On Output
Hi,
I'm having some trouble getting HTML tags to be parsed and not appear when displaying them in a dynamic text field;

here is the actionscript i'm using to display the data:

var XMLDoc:XML = new XML();

XMLDoc.ignoreWhite = true;
XMLDoc.onLoad = processXML;
XMLDoc.load ("XML/copy.xml");

function processXML(success:Boolean):Void {
if (success) {
trace ("Success");
_level0.txt_Headline.htmlText = XMLDoc.firstChild.firstChild.childNodes[1].attributes.headline;
_level0.txt_Body.htmlText = XMLDoc.firstChild.firstChild.childNodes[1].childNodes[0].firstChild;
} else {
trace ("Error.");
}
}

here is the XML that im pulling out:
<subnav name = "Overview" headline = "WHO WE ARE">
<body><![CDATA[<p>Next to our reputation, our greatest asset is our people. Design Forum’s team includes designers, strategists, brand experts, architects, engineers, implementation specialists, store planners, researchers and dozens of behind-the-scenes people who make it all happen.</p><p>We work with clients across all categories, including: retail, automotive, financial services, restaurants, as well as consumer products manufacturers.</p><p>The barn-inspired corporate headquarters is a paradigm of Design Forum’s approach and a symbol of our Midwestern work ethic. Built on the site of an old Ohio farm, its open spaces nourish a creative culture.</p>]]></body>
</subnav>

can't figure out why the <p></p> tags are appearing and not being parsed.

what am i doing wrong?

thanks for any help.
ian

URGENT Don't Want CDATA Node To HTML Escape Characters
Guys/Gals,
I need some very urgent help for a project that is on a tight deadline. I have a CDATA node that i'm loading into Flash that has some html in it. Let's just say this is it:

You are <font color='#FFFFFF'>very pretty</font>.<br><br>

When I trace out the xml after it is loaded into flash, it comes out as this:

You are <font color=&apos;#FFFFFF&apos;>very pretty</font>.<br><br>

I need it to come through with the tags in tact. How do I go about this?

THANKS VERY MUCH, cookies to the person who helps out!

Getting Html Text To Display From Xml File Usning CDATA
Hi
I am trying to get a link to work in the body text of a text block.
I am using CDATA but can not get this to translate to html in the flash. I have checked that the 'Render text as html' box is checked.
What is it that I am not doing? or not doing right?

Below is my AS and below that is my XML

========================
xml menu stripped down
======================


function CreateMenu(menu_xml) {
var items = menu_xml.firstChild.firstChild.childNodes;
for (var i = 0; i < items.length; i++)
{
if (items[i].attributes.type == "news")
{
var header = items[i].firstChild;
var article = items[i].childNodes[1];
var item_mc = menu_mc.attachMovie("menu_item", "item" + item_count, item_count);
item_mc._y = item_count * item_spacing;
item_count++;
item_mc.header_txt.text = header.firstChild.nodeValue; //
item_mc.main_mc.content_text = article.firstChild.nodeValue; // this is the content but is I use htmlText it throws an error
item_mc.main_mc.onRelease = DisplayInfo;
}
}
}
var news_xml = new XML();
news_xml.ignoreWhite = true;
news_xml.onLoad = function(success) {
if (success)
{
CreateMenu(this);
}
else
{
trace("Error loading XML file");
}
};
news_xml.load("news_url.xml");


===================
xml file below
==================


<?xml version="1.0" encoding="utf-8"?>
<menu>
<menuitems>
<item type="news">
<header>Heading</header>
<article><![CDATA[Some <br>text here<br><font size="16" color="#999999">And some text <a href="http://www.website.com" target="_blank"><b>here</b></a></font> <img src="any.jpg"/>]]></article>
</item>

</menuitems>
</menu>

XML/HTML/CDATA Into TextField With Mixed Bold And Embeded Fonts
Hi guys,

I've been looking for 3 days solid on an answer to this and wandered if you'd be able to shed some light. I have the following node in an XML file:


Code:
<Synopsis>
<![CDATA[If you know the names of the team member you wish to contact then you can email them by using the following:<br><b>firstname@website.co.uk<br />(e.g. joe@website.co.uk)</b> Alternatively please forward any queries or information to <b>info@website.co.uk</b><br /><br />Or call us on <b>0207 XXX XXXX</b> and we will be more than happy to help you with your query.<br /><br /><b>If you are coming to visit us we have provided useful links below to help make your journey easier to plan..]]>
</Synopsis>
In my fla I've imported a font library which works. I then dynamically create a textfield to hold the above.


Code:
var tf = new TextFormat();
tf.size =12;
tf.color=0x838383;
tf.font="45 Helvetica_Font Library";

var synopsis = find_us_mc.createTextField("synopsis_txt",find_us_mc.getNextHighestDepth(), 0, 5, 300, 50);
synopsis.setNewTextFormat(tf);
synopsis.html = true;
synopsis.autoSize = true;
comingFrom.embedFonts=true;
synopsis.multiline = true;
synopsis.wordWrap = true;
synopsis.htmlText = my_xml.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
If I don't embed the font then it displays in arial like:


Quote:




Alternatively please forward any queries or information to info@website.co.uk.. blah blah




- all correct apart from the font family.

If I embed the font then the text appears in normal with no bold bits.

I have tried putting a dynamic text box on the stage of my main movie in my imported font with bold selected, pressed the bold button and included every single glymph under the sun. But it still doesn't work. I know it's got something to do with the way the font is embeded.. I just can't find the solution and it's drving me nuts!!

Is there an actual solution for this? I don't really want to have to hack the XML as I may need it for a non-flash site.

H e l p !!

How Do I Render Html Tags Within A Cdata Section Of An Xml File Correcetly?
Hi guys

I've got an xml file which uses <![CDATA[ ]]> tags. I've got simple html code within these tags like <b> and <p>

when I read the content of these nodes into flash it is displaying the tags like this:
hi<br/>my<br/>name<br/>is<br/>Joe<br/>

and not

hi
my
name
is
Joe



Can anyone tell me what i'm doing wrong?

Thanks

XPathAPI Help?
I am creating an application that loads info from an xml file. It generates the city nodes to a list component. From the City list when a city is clicked i want it to pull up the siblingNodes into a data grid.
here is what i have so far. I dont know how to go about doing this.

Code:
function loadGulf(){
import mx.xpath.XPathAPI;
var cityXml:XML = new XML();
cityXml.ignoreWhite = true;
cityXml.onLoad = function(success:Boolean) {
trace("onload...");
if (success) {
trace("success...");
// Retrieve all Cities notes within /document/City.
var thePath_str:String = "/document/City"; // path of nodes
var city_array:Array = XPathAPI.selectNodeList(this.firstChild,
thePath_str);
for (var i:Number = 0; i < city_array.length; i++) {
trace(city_array[i].firstChild.nodeValue);
myList.addItem(city_array[i].firstChild.nodeValue);
}
} else {
trace("error loading XML");
}
};
cityXml.load("gulfCoast.xml");
}
loadGulf();
Thanks in advance

XPathAPI
If I publish for player 7 can I use the XPathAPI also is there any tutorials on how to use it with flash?

XPathAPI
Hi all,

I have been unable to get the XPathAPI to work. Here is my code:

var layerList:Array = XPathAPI.selectNodeList(this.firstChild, "/ViewContext/LayerList/Layer");

//grab the name
for(i = layerList.length - 1; i >= 0; i--)
{
var xmlNode:XMLNode = layerList;
var lName:String = XPathAPI.selectSingleNode(xmlNode.firstChild, "Name").firstChild.nodeValue;
}

The var lName is returned as undefined. Any ideas?

Thank you in advance!

Importing HTML/HTML Formatting
I've asked a similar question in evidently the wrong spot here, but am still having issues getting this to work. I'm new to Flash and know absolutely nothing about ActionScript. The flash project I'm working with can be seen here http://awcphotographs.com
What I'm trying to do, is make scrollable content within the white areas that include both text and images. If possible, differently aligned, formated and located text and the same with images. I want the entire area to scroll. Not just specific elements.
All of the 'tips' I've gotten thus far have been rather complicated and confusing dealing with images being converted to movie symbols with classes and etc...and I still can't even get that to work. Is there a more simple way to do this??
Also, is it possible to import a fully completed HTML page in to the white area and have the content scroll? Ex; I've got fully built pages in dreamweaver and I just want to put that data within the content area of the flash project. The page in question has text, images, a table and a CSS style sheet. Ultimately this would be the ideal situation so that I can build the elements as I want them in DW and just import them in to flash. Surely there must be some function within Flash that makes importing compatibility so much simpler??

Cdata Xml Problem Rendering "html" Formatet Text
Im having a problem with cdata markup text. For some reason flash will not render my html formatet text.


Code:
<text>
<![CDATA[My <b>html</b> formatet text ]]>
</text>
When i try to display my xml node in a text box in flash, my html markup gest displayed as regular text, including font tags ect...

I have tryed to use toString, but that somehow does not work either.


ActionScript Code:
var description1_obj:Object = content_xml.firstChild.childNodes.nodeValue;

var description1= description1_obj.toString();

this.content_txt.htmlText = description1;

Can anybody help me on this... Please
Regards Martin

[FMX04] AS - Showing Text Field As HTML Field With XML/CDATA.
Hey all -

Trying to get a text field in my Flash MX movie to pull from and XML file with CDATA tags to show as HTML. I've checked the box to render as HTML for the text data field... but I'm having problems with the Actionscripting.

The field from this line is what I need to recognize as HTML reading CDATA tags:

this.ref["textField"+i].text = subnodes[3].firstChild.toString()

I know I need to do more than just change it to ".html" instead of ".text" and have tried a couple things, but nothing seems to work.

Any help greatly appreciated!


Code:
//Create the XML Object
myXML = new XML ();
myXML.load(newXml);
myXML.ignoreWhite = true;

//Load XML file
myXML.load("PBintro.xml");
//Make a reference to current timeline
myXML.ref = this
// Parse XML and fetch
myXML.onLoad = function(success){
if(success){
var root = this.firstChild ;
nodes = root.childNodes
for(var i=0; i<nodes.length; i++) {
this.ref["Title_txt"+i].text = nodes[i].attributes.name
subnodes = nodes[i].childNodes
this.ref["Comments_txt"+i].text = subnodes[0].firstChild.toString()
this.ref["Link_txt"+i].text = subnodes[0].firstChild.toString()
this.ref["Link_txt"+i] = subnodes[1].firstChild.toString()
this.ref["holder_mc"+i].loadMovie(subnodes[2].firstChild.toString())
this.ref["textField"+i].text = subnodes[3].firstChild.toString()
this.ref["textField"+i] = subnodes[4].firstChild.toString()
}
} else trace("Error loading XML document")
}

XPathAPI Class
I am trying to learn about the xPathAPI class and i am not finding any good documentation about it. Does anyone know of a good source or tutorial using it. Any help would be wonderful

XPathAPI Problem
hi guys, i'm having the following problem:

i have an xml like this and when using xpath i cant retrieve the "nombre"'s attribute

Code:
<?xml version="1.0" encoding="UTF-8"?>
<solem>
<seccion nombre="equipo"></seccion>
<seccion nombre="productos"></seccion>
<seccion nombre="clientes"></seccion>
<seccion nombre="soluciones"></seccion>
</solem>
actionscript used:


Code:
import mx.xpath.XPathAPI;
var menu:Array = XPathAPI.selectNodeList(this.firstChild, "/solem/*");

for (var i = 0; i<menu.length; i++) {
trace(XPathAPI.selectSingleNode(this.firstChild, "/solem/seccion").attributes.nombre);
}
it traces me

equipo
equipo
equipo
equipo

any hints about this??

thanks

Looking For Working XPathAPI
Does anyone have an .fla, .as. and .xml that features a working XPathAPI they are willing to post up?

I"m trying to trouble shoot my own problem and would like to compare a working one with mine. For some reason the xpath static functions don't seem to be working for me. In the debugger I can see the appropriate classes being loaded.

Any help would be GREATLY APPRECIATED!

HTML Formatting
Does Flash support HTML table definitions?

HTML Formatting
Hey. I have a dyn txt box with HTML turned on. I am loading the txt from an internal variable. It's ignoring the HTML as well as the align right setting.
I think I read that it has to be loaded from an external txt file for the HTML to render properly. Is this true? Unfortuneately I must keep the text vars internal.
Any ideas?

Thanks.
1M.

HTML Formatting
Hi everybody!

I'm completely new to Flash CS3, but I'm trying to make a web site for my band using it. I have found lots of tutorials on the web explaining how to animate, scroll, navigate and so on, but I can't find anything that helps me answering this question:

What do I do to get text fields in Flash HTML formatted?

I have made the whole page with animations and navigation and everything I need, but the text fields I insert will only (for an obvious reason, I'm sure) be formatted as one spesific font and size at a time.

I'd be most grateful if anyone
a) understands my problem and
b) helps me out with it.

If there is an easy way to load an external HTML document into a text field (or something like it), I'd be happy if anyone knows about a tutorial about it.

I have uploaded a sample of the site, as far as I have come.
http://test.denderiverte.net/index.html

And as you see (although the text is in Norwegian), the look of the site would have been slightly improved by a little variance in fonts, size and colours.

In advance:
thanks!


Pål

HTML Formatting In XML
Hi all.

I have inherited a Flash file from a previous developer that has a "map" with an external XML file for the contact details. Its all working fine and its not too bad, having the attributes as Address, Contact, Phone etc... but now the client wants to amend one item to include 2 contact people and different attributes.

So now I am trying to include some HTML formatting within the fields, but when I insert the <br> tag or anything else, it a) stops processing the XML and b) stops the movieclip animations for the "map" locations as well.

I cant share the files because its a corporate project... but I am wondering if anyone knows of anything I have forgotten? The dynamic text box is a htmlText field, and I figured it would be as simple as putting accepted tags?

whitespace is ignored. hmm?

HTML Formatting
Is there anyway to tell Flash that when an external text file is being read in that the <strong> and <em> tags should be <b> and <i> instead?

I've been looking at different options for a CMS that will allow HTML formatting in text files, but it seems that all the CMS's I am working with are applying HTML tags that Flash doesn't understand.

I first tried a combination of FlashTextEditor and FlashDB, which seemed pretty promising, except I couldn't figure out how to read the present files, edit them, and then resave with existing formatting. This whole situation really left me feeling like a moron, especially without help from others.

My next option was using pinEdit which also seemed very promising (more so than the previous combination) except that not only was it dropping in tags that Flash doesn't understand, there was some strange formatting that was going on when looking at the text files themselves through my browser. I could see the formatting, just not the tags unless I viewed source, which I've never seen happen before. The creator of the script was so vauge in his information when I asked for assistance that I have since given up on the situation.

In order for me to deliver my websites I must be able to have my clients update their own sections. Had I had more time I'd simply charge for updates until I came across some money to pay someone to help, considering finding help any other way is almost impossible. I was really hoping to get my FlashDB and FlashTextEditor combination working but that didn't happen.

Sorry for the big post...had a lot to say. Anyone willing to help or offer support of any kind would be greatly appreciated.

HTML Formatting
I've been trying to format some strings in a dynamic textbox that has the html option on.
I can do basic things such as make part of the string bold with <b>bold</b> but I can't figure out how to change the colour etc.
I tried this (I ma:

Code:
<span style="color: #3C3C3C;">Make this grey</span>
But it has no effect.
What html tags can I use and how can I change the colour of certain parts.

I'd like to do something like:

Code:
<b>user</b>: message here
<b>me</b>: <span style="color: #3C3C3C">Message here</span>

XML + HTML Formatting ...
I'm using <![CDATA[ ... ]]> in my XML. Here's the as:


ActionScript Code:
myText.htmlText = true;
myText.wordWrap = true;
myText.multiline = true;
myTextContent = new XML();
myTextContent.ignoreWhite = true;
myTextContent.load("ultrashock.xml");
myTextContent.onLoad = function(success)
{
        if(success)
        {
                xmlData = this.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
                myText.text = xmlData;
        }
}


With this action script importing the XML, my nodes with the CDATA are still just displayed as text, the HTML tags are just shown as plain text.

But, when I add two lines of code it works fine, here's the new code:


ActionScript Code:
myTextStyle = new TextField.StyleSheet();
myText.styleSheet = myTextStyle;
myText.htmlText = true;
myText.wordWrap = true;
myText.multiline = true;
myTextContent = new XML();
myTextContent.ignoreWhite = true;
myTextContent.load("ultrashock.xml");
myTextContent.onLoad = function(success)
{
        if(success)
        {
                xmlData = this.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
                myText.text = xmlData;
        }
}


I've tried everything I can by just importing regular XML with CDATA info and nothing works. But for some reason when these two style sheet lines are added. It works fine. Is this the only way to get this to work?

I'm working in MX 2004 Prof. Fun stuff.

Formatting Xml Having Html
i have an xml file containing Html text with tags like bold,italic,bullets,,,and--,<p>etc..

it is working on loading according to the format....

the problem is that bold & italic are not working
the class aplication by making CSS is also going on with tags like these or <h1>dbdb</h1>

Using Contains Comparison In Mx.xpath.XPathAPI
Is it possible to use something like this using m.xpath.XPathAPI parser

var recordPath:String = "/RECORDLIST/RECORDS/RECORD[contains(@name,'192.COM')]";
title_array = mx.xpath.XPathAPI.selectNodeList(codeFeed.firstChi ld, recordPath);

I am trying to match the values in the attribute name that contain "192.com"

This should be possible, but am not able to get any examples or documentation could someone help?

Thanks
KashSen

XPathAPI To Load Images
i am trying to use XPathAPI to load images into my flash movie and am having a little trouble. i think either my xml isn't formed well or i am confused on how to access it from actionscript. can anyone give any suggestions?

thank you for any help...







Attach Code

the AS --

import mx.xpath.XPathAPI;
var productsXml:XML = new XML();
productsXml.ignoreWhite = true;
productsXml.onLoad = function(success:Boolean) {
if (success) {
var theXPathString:String = "/products/*";
var theDataString:String = XPathAPI.selectSingleNode(this.firstChild, theXPathString);
} else {
trace("not working");
}
var images:Array = XPathAPI.selectSingleNode(this.firstChild, theXPathString);
var products_array:Array = new Array();
products_array = XPathAPI.selectNodeList(this.firstChild, theXPathString);
for (var i = 0; i<images.length; i++) {
products_array.push({src:images[i].firstChild});
}
displayProducts(products_array);
//trace(images);
};
productsXml.load("products.xml");
function displayProducts(products_array:Array) {
var productsLength:Number = products_array.length;
for (var i = 0; i<productsLength; i++) {
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
mcLoader_mcl.loadClip(products_array[i].src, thisMC);
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
}
}
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();


the XML--
<?xml version="1.0"?>
<products>
<img src="img/anywhere_bottle_s.jpg" label="" href=""/>
<img src="img/anywhere_s.jpg" label="" href=""/>
<img src="img/atbc_bleach_s.jpg" label="" href=""/>
<img src="img/atbcb_s.jpg" label="" href=""/>
<img src="img/bleach_pen_s.jpg" label="" href=""/>
<img src="img/ccu_s.jpg" label="" href=""/>
<img src="img/cdbc_s.jpg" label="" href=""/>
<img src="img/cdbs_s.jpg" label="" href=""/>
<img src="img/cdkc_citrus_s.jpg" label="" href=""/>
<img src="img/cds_s.jpg" label="" href=""/>
<img src="img/cdw_fresh_s.jpg" label="" href=""/>
<img src="img/cdw_lemon_s.jpg" label="" href=""/>
<img src="img/cdw_leva_s.jpg" label="" href=""/>
<img src="img/cdw_orange_s.jpg" label="" href=""/>
<img src="img/cdw_togo_s.jpg" label="" href=""/>
<img src="img/cdw_togo3_s.jpg" label="" href=""/>
</products>

XPathAPI To Load Images
i am trying to use XPathAPI to load images into my flash movie and am having a little trouble. i think either my xml isn't formed well or i am confused on how to access it from actionscript. can anyone give any suggestions?

thank you for any help...

Attach Code

the AS --

import mx.xpath.XPathAPI;
var productsXml:XML = new XML();
productsXml.ignoreWhite = true;
productsXml.onLoad = function(success:Boolean) {
if (success) {
var theXPathString:String = "/products/*";
var theDataString:String = XPathAPI.selectSingleNode(this.firstChild, theXPathString);
} else {
trace("not working");
}
var images:Array = XPathAPI.selectSingleNode(this.firstChild, theXPathString);
var products_array:Array = new Array();
products_array = XPathAPI.selectNodeList(this.firstChild, theXPathString);
for (var i = 0; i<images.length; i++) {
products_array.push({src:images[i].firstChild});
}
displayProducts(products_array);
//trace(images);
};
productsXml.load("products.xml");
function displayProducts(products_array:Array) {
var productsLength:Number = products_array.length;
for (var i = 0; i<productsLength; i++) {
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
mcLoader_mcl.loadClip(products_array[i].src, thisMC);
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
}
}
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();


the XML--
<?xml version="1.0"?>
<products>
<img src="img/anywhere_bottle_s.jpg" label="" href=""/>
<img src="img/anywhere_s.jpg" label="" href=""/>
<img src="img/atbc_bleach_s.jpg" label="" href=""/>
<img src="img/atbcb_s.jpg" label="" href=""/>
<img src="img/bleach_pen_s.jpg" label="" href=""/>
<img src="img/ccu_s.jpg" label="" href=""/>
<img src="img/cdbc_s.jpg" label="" href=""/>
<img src="img/cdbs_s.jpg" label="" href=""/>
<img src="img/cdkc_citrus_s.jpg" label="" href=""/>
<img src="img/cds_s.jpg" label="" href=""/>
<img src="img/cdw_fresh_s.jpg" label="" href=""/>
<img src="img/cdw_lemon_s.jpg" label="" href=""/>
<img src="img/cdw_leva_s.jpg" label="" href=""/>
<img src="img/cdw_orange_s.jpg" label="" href=""/>
<img src="img/cdw_togo_s.jpg" label="" href=""/>
<img src="img/cdw_togo3_s.jpg" label="" href=""/>
</products>

HTML Formatting On Variables...
Hi, 2 questions:

1.

The following code works perfectly to make the text bold (so long as Render as HTML is checked)

mytext="< b>hello world< /b>"

My question is, how do I use html formatting on dynamic variables. For example, if instead of "hello world", I wanted say MESSAGE which is another variable.

I've tried using many different combinations but none seem to work. Can anyone help?


2.

I have a dynamic text box which is approx 4 lines high. Now, the variable is on a loop, so every so often, it will add a new line and insert a new entry like so:

entry 1
entry 2
entry 3... and so on

now, after I get past the fourth entry, it does not automatically scroll up - is it possible to control this somehow? I want it to work similar to a chat app where the last message is shown and then it moves up when a new message is inserted.


Thanks in advance for any help.

Copyright © 2005-08 www.BigResource.com, All rights reserved