dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: load xml into mc symbols

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    3

    load xml into mc symbols

    I'm new to incorporating xml into my flash. I've used components that do all the linking for me, but have never tried doing the code myself. My project is a simple slide show, that has transitions on the timeline that are very important to the project. I have created an image holder movie clip symbol which is the same size as my images. I have created the slideshow using multiple instances (each with its own instance name slide01, slide02, etc) of this holder. All I want to do is load the .jpg files in from an xml file to populate the holder files before run time. I have gotten the code to work for the first image, but none of the others will populate. I am attempting to load the xml data into an array, then pull from the array to populate the mc symbols. I modified the code I found in a tutorial. Please help!

    My AS2:
    Code:
    var x:XML = new XML();
    x.ignoreWhite = true;
    
    var urls:Array = new Array();
    
    x.onLoad = function(success) {
    	var photos:Array = this.firstChild.childNodes;
    	for(i=0;i<photos.length;i++) {
    		
    		urls.push(photos[i].attributes.url);
    	}
    	
    	slide01.loadMovie(urls[0]);
    	slide02.loadMovie(urls[1]);
            slide03.loadMovie(urls[2]);
            slide04.loadMovie(urls[3]);
            slide05.loadMovie(urls[4]);
            slide06.loadMovie(urls[5]);
            slide07.loadMovie(urls[6]);
            slide08.loadMovie(urls[7]);
            slide09.loadMovie(urls[8]);
            slide10.loadMovie(urls[9]);
    }
    
    x.load("slideshow1.xml");
    My XML:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <slideshow>
    <photo url="01.jpg" />
    <photo url="02.jpg" />
    <photo url="03.jpg" />
    <photo url="04.jpg" />
    <photo url="05.jpg" />
    <photo url="06.jpg" />
    <photo url="07.jpg" />
    <photo url="08.jpg" />
    <photo url="09.jpg" />
    <photo url="10.jpg" />
    
    </slideshow>

  2. #2
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Looks like you're missing an unlaod image statement.

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    3

    Thumbs up Solved

    So I have solved my problem. The issue wasn't with my code at all, but within my time line. I had my image holder movie clip instances spread throughout my time line. But in order for them to be effected by the code they needed to be on the same frame where the code is being executed. So I added them all at frame 1 and made them all transparent until I need them.

    Thanks to everyone who took a look.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center