Highlighted

HTML Canvas - loading multiple images using xml file

New Here ,
May 17, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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
}

TOPICS
ActionScript

Views

896

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

HTML Canvas - loading multiple images using xml file

New Here ,
May 17, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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
}

TOPICS
ActionScript

Views

897

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 17, 2020 0
Adobe Community Professional ,
May 17, 2020

Copy link to clipboard

Copied

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
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 17, 2020 0
New Here ,
May 19, 2020

Copy link to clipboard

Copied

Perfect thanks.

 

Andrew

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
Adobe Community Professional ,
May 22, 2020

Copy link to clipboard

Copied

you're welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 22, 2020 0
New Here ,
Jul 07, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2020 0
kglad LATEST
Adobe Community Professional ,
Jul 08, 2020

Copy link to clipboard

Copied

you're both welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 08, 2020 0