all groups > flash actionscript > april 2004 >
You're in the

flash actionscript

group:

Importing XML into a TextField


Importing XML into a TextField Dave Merwin
4/26/2004 11:54:53 PM
flash actionscript:
A lot of tutorials want me to load XML into a TextArea. I do not want to do
that. I can not get this to work. Any ideas?

Here is my code:

//init TextArea component
//_root.createTextField('myText', 1, 0, 0, 200, 300)
myText.html=true;
myText.wordWrap=true;
myText.multiline=true;
myText.border=true;

//load css
/*kungFuStyle = new TextField.StyleSheet();
kungFuStyle.load ("kungfu.css");
myText.styleSheet=kungFuStyle;*/

//load XML
var kungFu_xml=new XML();
kungFu_xml.load("kungfu.xml");
kungFu_xml.ignoreWhite=true;
kungFu_xml.onLoad=function(success)
{
if(success)
{
myText.text=kungFu_xml;
}
}

Re: Importing XML into a TextField Laiverd.COM
4/27/2004 8:51:29 AM
Don't understand the problem. If you don't want to use XML, don't use it?!
What am I missing?

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: Importing XML into a TextField Dave Merwin
4/27/2004 4:08:04 PM
I'm a knuckle head. The problem is that it will not display the XML. It actually displays the XML tags. Sorry fo rthe confusion.

Re: Importing XML into a TextField gryllsie
4/27/2004 4:33:36 PM
Try this:

myText.text=kungFu_xml.firstChild.nodeValue;

Re: Importing XML into a TextField Dave Merwin
4/27/2004 4:44:36 PM
It works, but I do not know why.

First I entered what you wrote verbatim and the value displayed as null.

Then I tried this: myText.text=kungFu_xml.firstChild.firstChild;

It worked, but I have NO idea why. Could you let me know?

Here is the current code.

kungFu_xml = new XML();
kungFu_xml.ignoreWhite=true;
kungFu_xml.load("kungfu.xml");
kungFu_xml.onLoad=function(success)
{
if(success){
myText.htmlText=kungFu_xml.firstChild.firstChild;
trace(kungFu_xml);
}
}

//init TextArea component
_root.createTextField('myText', 1, 0, 0, 200, 300)
myText.border=true;
myText.type="dynamic";

Re: Importing XML into a TextField Mr. Bill82
4/27/2004 4:45:56 PM
The problem is you're referring to the XML as an entire object and not it's
properties. If you're just trying to display a paragraph of text for example,
in your XML file maybe you'll have something like:

<myParagraph>
<myText>
blah de blah................
</myText>
</myParagraph>

In Flash you should have something like,

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
if (success) {
_root.FillTextBox(myXML);

}
}
myXML.load("test.xml");

function FillTextBox(myXML){
_root.myTextBox.text = myXML.childNodes[0].firstChild.nodeValue;
}

That *should* work.. no guarantees ;)

-Bill



Re: Importing XML into a TextField Dave Merwin
4/27/2004 4:54:57 PM
Thanks for all your help. Do you know any good tutorials to help me with this?

Re: Importing XML into a TextField Mr. Bill82
4/27/2004 5:07:40 PM
You could try something like:


http://www.flashkit.com/tutorials/Dynamic_Content/A_Simple-Joachim_-802/index.ph
p

That's a little more advanced, but if you dive right into it, you should be
learning in no time.

Cheers,

-Bill

AddThis Social Bookmark Button