Skip to main content
Participating Frequently
May 17, 2020
Answered

HTML Canvas - loading multiple images using xml file

  • May 17, 2020
  • 3 replies
  • 1904 views
Hi all,
 

I am trying convert an Edge Animate project to Animate CC where single images are loaded into a series of empty movie clips using a frame actions and a xml file. These movie clips are all prepositioned in a single movie clip that has an initiating action to load all the images before playing the timeline and fading up all the images in turn.

I have solved the loading of the images once I have the 'imageid' (MC instance) and 'small_url'. However, I cannot seem to get the data from the XML file into the relevant variables.

the xml is structured like this:

<images>
<imagedata ID = "image1_1">
    <imageid>image1_1</imageid>
    <small_url>images/small/HF0307_008.jpg</small_url>

</imagedata>
<imagedata ID = "image1_2">
    <imageid>image1_2</imageid>
    <small_url>images/small/HF0001_187.jpg</small_url>

</imagedata>
<imagedata ID = "image1_3">
    <imageid>image1_3</imageid>
    <small_url>images/small/HF0226_157.jpg</small_url>

</imagedata>
<images>

The code I have tried with no success is:

var myimageid = "theMovieClipInstanceName";

var imagedata = new XMLHttpRequest(); 

imagedata.addEventListener("load", imagedataF);imagedata.open("GET", "myXMLfile", true);  
imagedata.setRequestHeader("Content-Type", "text/xml");imagedata.send();


function imagedataF(e) { 

var imagedatafile = e.target.responseXML;

//from here is where I am uncertain what to do!!
//I want to identify the xml element with child[0] that = "myimageid" and then set the 'smallurl' variable to this value.

var images = imagedatafile.getElementsByTagName("imagedata");

var smallurl = images.getElementsByTagName("imageid").[0] = myimageid;  

//use variable "smallurl" to load images

}

Been trying everything with no joy.

Any help would be much appreciated.

This topic has been closed for replies.
Correct answer kglad

try:

var  imageID_array;


function imagedataF(e) {
parser = new DOMParser();
var xml = parser.parseFromString(e.target.response, "text/xml");
myImagesID_array = xml.getElementsByTagName("imagedata");

// and your ith smallurl is myImagesID_array[i].getElementsByTagName("small_url")[0].childNodes[0].nodeValue
}

3 replies

Participant
July 7, 2020

I have tried 

var  imageID_array;


function imagedataF(e) {
parser = new DOMParser();
var xml = parser.parseFromString(e.target.response, "text/xml");
myImagesID_array = xml.getElementsByTagName("imagedata");

// and your ith smallurl is myImagesID_array[i].getElementsByTagName("small_url")[0].childNodes[0].nodeValue

The article to grow ps4 jailbreak exploits. This worked for me also. Thanks

kglad
Community Expert
Community Expert
July 8, 2020

you're both welcome.

Participating Frequently
May 19, 2020

Perfect thanks.

 

Andrew

kglad
Community Expert
Community Expert
May 22, 2020

you're welcome.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 17, 2020

try:

var  imageID_array;


function imagedataF(e) {
parser = new DOMParser();
var xml = parser.parseFromString(e.target.response, "text/xml");
myImagesID_array = xml.getElementsByTagName("imagedata");

// and your ith smallurl is myImagesID_array[i].getElementsByTagName("small_url")[0].childNodes[0].nodeValue
}