dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: How do I import a JPEG from an XML file?

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    137

    How do I import a JPEG from an XML file?

    Hey there I've been looking for a simple tutorial on how to do this, but so far I haven't found one, I'm trying to load an external jpg using an xml file in to an empty movie clip.....please help!!

    Thanks

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Posts
    2,049
    visit this site and look for "Flash and XML slideshow"

    www.gotoandlearn.com

    it will show basicly what you want

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    137
    hey thanks for your reply, I went to the site and downloaded the file but I couldn't view it........any other suggestions?

  4. #4
    Senior Member
    Join Date
    Oct 2004
    Posts
    2,049
    here is some code

    action script panel
    PHP Code:
    var x:XML = new XML();
    x.ignoreWhite true;

    var 
    urls:Array = new Array();
    var 
    captions:Array = new Array();
    var 
    whoIsOn:Number;

    x.onLoad = function(success) {
        var 
    photos:Array = this.firstChild.childNodes;
        for(
    i=0;i<photos.length;i++) {
            
    urls.push(photos[i].attributes.url);
            
    captions.push(photos[i].attributes.caption);
        }
        
    holder.loadMovie(urls[0]);
        
    caption.text captions[0];
        
    whoIsOn 0;
    }

    x.load("lost.xml");

    previous.onRelease = function() {
        if(
    whoIsOn 0) {
            
    whoIsOn--;
            
    holder.loadMovie(urls[whoIsOn]);
            
    caption.text captions[whoIsOn];
        }
    }

    next.onRelease = function() {
        if(
    whoIsOn urls.length-1) {
            
    whoIsOn++;
            
    holder.loadMovie(urls[whoIsOn]);
            
    caption.text captions[whoIsOn];
        }

    xml file
    PHP Code:
    -
        <
    slideshow>
    <
    photo url="lost1.jpg" caption="Sayid tries to explain to electronics theory to Kate."/>
    <
    photo url="lost2.jpg" caption="Locke tries again to explain to Jack why he's not crazy."/>
    <
    photo url="lost3.jpg" caption="Its confirmed, Jack's dad is dead as a doornail."/>
    <
    photo url="lost4.jpg" caption="Boone getting saved, but it won't do him any good."/>
    <
    photo url="lost5.jpg" caption="Jack and Hurley saving Claire from the wreckage."/>
    </
    slideshow
    Hope this will help you get your project going

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Posts
    137
    thanks man I tryed it and it works...... I appreciate the help

  6. #6

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