PDA

View Full Version : Loading text and image with XML


[email protected]
03-06-2009, 10:27 PM
I am trying to load a single image and some text into a Flash doc with XML.
I can get the image to load fine but everything I have tried to get the text to load doesn't work. Could anyone tell me what needs to be added to this in order for text to be added?

I have a movie clip "imageLoader" which th image does load into. I also have a movie clip "textLoader" which I would like the copy to load into.

Here is what I have:

Actionscript
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success){
if(success){
// the line below load the pictures in an empty movie clip manually created and called imageLoader
loadMovie(myXML.childNodes[0].firstChild.firstChild.nodeValue, imageLoader);
loadMovie(myXML.childNodes[1].firstChild.firstChild.nodeValue, textLoader);
} else {
}
}
myXML.load("contact.xml");

XML:
<content>
<imagePath>01.jpg</imagePath>
<imagePath>Blah blah blah, sample text</imagePath>
</content>

Thanks


Sorry if this looks familiar. I posted a similar thread few days ago but didn't have a chance to get back to those who helped and had more questions.

paveloosha
03-07-2009, 05:36 AM
Hi, You can try it into this way... put a dynamic text box into the movieclip "textLoder". name it "myTxt". then use textLoader.myTxt.text=myXML.childNodes[1].firstChild.firstChild.nodeValue; insted of loadMovie(myXML.childNodes[1].firstChild.firstChild.nodeValue, textLoader);

[email protected]
03-07-2009, 05:08 PM
This is what I have now and I still don't see the text:

Actionscript:
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success){
if(success){
// the line below load the pictures in an empty movie clip manually created and called imageLoader
loadMovie(myXML.childNodes[0].firstChild.firstChild.nodeValue, imageLoader);
textLoader.myTxt.text=myXML.childNodes[1].firstChild.firstChild.nodeValue;
} else {
}
}
myXML.load("myImage.xml");


XML:
<content>
<imagePath>01.jpg</imagePath>
<textPath>Blah blah blah, sample text</textPath>
</content>

Does anyone have any thoughts?

paveloosha
03-08-2009, 04:36 PM
Did you placed a dynamic textbox at your movieclip textLoader? Can you attach the fla file so I can check out your structure and coding?

[email protected]
03-09-2009, 04:44 AM
Attached are my files.

Thanks again

paveloosha
03-09-2009, 05:21 AM
Use this code at first frame... myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success){
if(success){
// the line below load the pictures in an empty movie clip manually created and called imageLoader
loadMovie(myXML.childNodes[0].childNodes[0].firstChild.nodeValue, imageLoader);
textLoader.myTxt.text=myXML.childNodes[0].childNodes[1].firstChild.nodeValue;

} else {
}
}
myXML.load("myImage.xml");