|
-
Xml Html Cdata Blues
I'm am trying to import html-formatted text into flash using CDATA.
PHP Code:
<english_btn><![CDATA[Try using <b>bold</b> text]]></english_btn>
the nodevalue is retrieved with
_root.english_btn.text = content.firstChild.childNodes[0].firstChild.nodeValue;
However the dynamic-HTML textfield displays
PHP Code:
Try using <b>bold</b> text
What the h*** is wrong?
//podenphant
Last edited by podenphant; 01-22-2003 at 11:18 AM.
-
no fuzz
hmmm ...
I discovered the problem.
I was targetting the textvalue with flash6's textfield instancename with:
_root.english_btn.text = content.firstChild.childNodes[0].firstChild.nodeValue;
when I changed to setting the variable directly i worked perfectly
english = content.firstChild.childNodes[0].firstChild.nodeValue;
//pod
-
Senior Member
Crap I have this problem too. Anyone have a solution for this. I need to pass variables across levels so I have to target exatly a certain way.
-
Retired Mod
Re: no fuzz
Originally posted by podenphant
hmmm ...
I discovered the problem.
I was targetting the textvalue with flash6's textfield instancename with:
_root.english_btn.text = content.firstChild.childNodes[0].firstChild.nodeValue;
when I changed to setting the variable directly i worked perfectly
english = content.firstChild.childNodes[0].firstChild.nodeValue;
//pod
you need to target the htmlText property of the textfield not the text property.
if you use;
_root.english_btn.htmlText = content.firstChild.childNodes[0].firstChild.nodeValue;
it should display just fine.
it's recommended that you use the instance name for a text field rather than the variable name. By using the instance name you can access all the methods and properties for the text field object.
hth
-
If you want to setup a text field as HTML enabled.... you will want to set the 'html' property to true, and then assign the htmlText property to hold the HTML tagged text.
* Dangit aversion - you posted right while I was writing mine... *
-
Senior Member
Nope doesn't work. I did it like you said reference the object and not the variable.
with(_level0) {
// Set variables ----------------
SubTitleVar = this.SubTitle;
SubContent.htmlText = this.SubContent;
}
-
... it does work...
Here's a cut-n-paste example to place in a blank FLA::
PHP Code:
_root.createTextField("display", 10,10,10,10,10);
_root.display.autoSize="left";
_root.display.html=true;
_root.display.htmlText="<i>italics</i>";
_root.myXML = new XML("<top><inside><![CDATA[<b>bold</b>]]></inside></top>");
_root.display.htmlText=_root.myXML.childNodes[0].childNodes[0].firstChild.nodeValue;
If you're having problems with targeting, and not with getting CDATA-ized text to display properly in an HTML enabled text field, then maybe I don't understand your question.
-
Senior Member
Hmmmm not sure where to start. Okay first, in my XML doc I have the CDATA tag. Is that wrong or is it better to add that in the Flash doc?
Hard to give the AS code since it's so huge but to make a long story short I have a loop that creates the variable for content dynamically based on what frame I am on and X number of items in the XML doc.
navItem.SubContent = oContent_xml_navs[i].childNodes;
Then
_level0.SubContent.htmlText = this.SubContent;
It's not a matter of targeting. Cause the data is getting passed. The HTML text box isn't rendering the HTML tags. Its actually displaying the b tags as if they were are part of the string.
But if I test by sending a regular string of content within p tags it works fine. Something with how the data is set and/passed.
Last edited by rob5150; 03-03-2003 at 06:37 PM.
-
If you can get my cut-n-paste example to work, and what you say is true, then...
1. you're not asking for the nodeValue of the correct node, or...
2. you're assigning the text property when you should be assigning the htmlText property.
We been over #2 in this thread...
As for #1...
Look at the following examples closely:
This is WRONG.
PHP Code:
_root.createTextField("display", 10,10,10,10,10);
_root.display.autoSize="left";
_root.display.html=true;
_root.display.htmlText="<i>italics</i>";
_root.myXML = new XML("<top><inside><![CDATA[<b>bold</b>]]></inside></top>");
_root.display.htmlText=_root.myXML.childNodes[0].childNodes[0].firstChild;
This is RIGHT.
PHP Code:
_root.createTextField("display", 10,10,10,10,10);
_root.display.autoSize="left";
_root.display.html=true;
_root.display.htmlText="<i>italics</i>";
_root.myXML = new XML("<top><inside><![CDATA[<b>bold</b>]]></inside></top>");
_root.display.htmlText=_root.myXML.childNodes[0].childNodes[0].firstChild.nodeValue;
The wrong example exhibits the problems you're having.
Last edited by VAYKENT; 03-03-2003 at 07:03 PM.
-
Senior Member
Yes! Thank you!
I FINALLY see what the problem was. Took me a little while to understand it. I was being thrown off because the data was still being sent without using nodeValue. But that does make sense now that I look at it. Well that's load off my mind. XML is pretty new to me so bare with me.
Would you mind answering a couple of questions about formatting? I realize Flash supports a few HTML tags. Like P, FONT etc. First question is, when I add paragraph tags to the content it doesn't return the content the way a browser would. Meaning, a seperation between paragraphs. It merely returns to the next line. Is that typical and is there a formatting way of handling that in flash OR is it just a matter of adding another P tag. OR is flash could I leverage TextFormat.leading in flash to handle the space between P tag areas. The other question I have is about styles of a sort. For instance, if I wrap a block of text with the B tag is there a way of styling that out in Flash OR do I need to do a find&replace of those characters with say a font tag, different size and color in flash?
Thanks for all your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|