dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML Image Viewer question

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    171

    XML Image Viewer question

    Hello all,
    I'm currently working on a modified version of Macromedias Image Viewer.
    With the added features from tupps my movie now has auto play, stop, go to end slide (swf's) etc.
    At the moment i have the following code:
    PHP Code:
    <?xml version="1.0"?>

    <Slides>
      <slideNode jpegURL="images/pic_1.swf">Picture 1</slideNode>
      <slideNode jpegURL="images/pic_2.swf">Picture 2</slideNode>
      <slideNode jpegURL="images/pic_3.swf">Picture 3</slideNode>
      <slideNode jpegURL="images/pic_4.swf">Picture 4</slideNode>
      <slideNode jpegURL="images/pic_5.swf">Picture 5</slideNode>
      <slideNode jpegURL="images/pic_6.swf">Picture 6</slideNode>
      <slideNode jpegURL="images/pic_7.swf">Picture 7</slideNode>
      <slideNode jpegURL="images/pic_8.swf">Picture 8</slideNode>
      <slideNode jpegURL="images/pic_9.swf">Picture 9</slideNode>
    </Slides>
    This group of slides (swf's) is one Presentation
    What i now want to be able to do is add a combo box that displays the Presentation title in it and any other Presentation titles that may exist (at a later date).
    Can anyone tell me how i go about this? Can i add a <Presentation> tag to my xml file with the name of that Presentation or do i need to create a new xml file for each Presentation?

    Any ideas greatly appreciated.

    Regards,
    Suzy

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    One way to do this it to create your XML files like such:

    PHP Code:
    <presentations>
    <
    presentation name="Pres1">
    <
    Slides>

      <
    slideNode jpegURL="images/pic_1.swf">Picture 1</slideNode>

      <
    slideNode jpegURL="images/pic_2.swf">Picture 2</slideNode>

      <
    slideNode jpegURL="images/pic_3.swf">Picture 3</slideNode>

      <
    slideNode jpegURL="images/pic_4.swf">Picture 4</slideNode>

      <
    slideNode jpegURL="images/pic_5.swf">Picture 5</slideNode>

      <
    slideNode jpegURL="images/pic_6.swf">Picture 6</slideNode>

      <
    slideNode jpegURL="images/pic_7.swf">Picture 7</slideNode>

      <
    slideNode jpegURL="images/pic_8.swf">Picture 8</slideNode>

      <
    slideNode jpegURL="images/pic_9.swf">Picture 9</slideNode>

    </
    Slides>

    </
    presentation>

    <
    presentation name="Pres2">
    <
    Slides>

      <
    slideNode jpegURL="images/pic_1.swf">Picture 1</slideNode>

      <
    slideNode jpegURL="images/pic_2.swf">Picture 2</slideNode>

      <
    slideNode jpegURL="images/pic_3.swf">Picture 3</slideNode>

      <
    slideNode jpegURL="images/pic_4.swf">Picture 4</slideNode>

      <
    slideNode jpegURL="images/pic_5.swf">Picture 5</slideNode>

    </
    Slides>

    </
    presentation>


    </
    presentations
    What I would do is create an new movie that contains your current movie as a movie clip. Then that movie would be responsible for loading the XML into the system. Once you choose the presentation you want you could pass the child nodes of that presentation to the image display movie clip and all your current features would work.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    171
    Hello tupps,
    I have tried several ways but am not quite there.
    At the moment i can successfully display the Presentation names in the dropdown list however my image viewer results are not showing. It appears to be calling the Presentation nodes, not the slides.
    I've tried putting them in a movieclip of there own but to know avail.

    This is the actionscript for my dropdown list:
    Code:
    myFavorits_cb._visible = 0;
    myLinks_xml = new XML();
    myLinks_xml.ignoreWhite = true;
    myLinks_xml.load("xml/images.xml");
    myLinks_xml.onLoad = function() {
        
        var l = myLinks_xml.childNodes[0].childNodes.length;
        for (var i = 0; i<l; i++) {
            
            var c = myLinks_xml.childNodes[0].childNodes[i].childNodes[0].childNodes;
            
            var v = myLinks_xml.childNodes[0].childNodes[i].childNodes[1].childNodes;
            
            myFavorits_cb.addItem(c, v);
        }
        
        myFavorits_cb._visible = 1;
    };
    function openUrl(x) {
        getURL(x.getValue(), "_blank");
    }
    and this is the actionscript for loading the images:
    Code:
    images_xml = new XML();
    images_xml.onLoad = startImageViewer;
    images_xml.load("xml/images.xml");
    images_xml.ignoreWhite = true;
    // 
    function startImageViewer(success) {
        if (success == true) {
            rootNode = images_xml.firstChild;
            // 'totalImages' is the variable name set to correspond with the the dynamic text instance of 'totalImages'
            totalImages = rootNode.childNodes.length;
            // [ totalImages = rootNode.childNodes.length; ] gets the total number of childNodes (total number of image and text files) in your .xml document
            firstImageNode = rootNode.firstChild;
            currentImageNode = firstImageNode;
            // 'currentIndex' is the variable name set to correspond with the dynamic text instance of 'currentIndex'
            currentIndex = 1;
            // [ currentIndex = 1; ] sets the viewer to play the first childNode (first image and text file) in your .xml document
            updateImage(firstImageNode);
        }
    }
    // 
    // Updates the current image with new image and text
    function updateImage(newImageNode) {
        // 'imagePath' is the variable name set to correspond with the .jpeg file name located in your .xml document
        imagePath = newImageNode.attributes.jpegURL;
        // 'imageText' is the variable name for the instance 'textArea'
        imageText = newImageNode.firstChild.nodeValue;
        // 'targetClip' is the instance name for the movie clip 'imageArea', this is where all your image files from your .xml document are loaded
        targetClip.loadMovie(imagePath);
        // IMPORTANT : RESCALING THE SIZE OF THE 'imageArea' MOVIE CLIP WILL AFFECT THE ORIGNAL SIZE OF WHATEVER IMAGE YOU HAVE IN YOUR IMAGES FOLDER
    }
    // 
    next_btn.onRelease = function() {
        nextImageNode = currentImageNode.nextSibling;
        if (nextImageNode == null) {
            break;
        } else {
            currentIndex++;
            updateImage(nextImageNode);
            currentImageNode = nextImageNode;
        }
    };
    // 
    // Event handler for 'Previous image' button
    back_btn.onRelease = function() {
        previousImageNode = currentImageNode.previousSibling;
        if (previousImageNode == null) {
            break;
        } else {
            currentIndex--;
            currentImageNode = previousImageNode;
            updateImage(previousImageNode);
        }
    };
    last_btn.onRelease = function() {
        nextImageNode = rootNode.lastChild;
        if (nextImageNode == null) {
            break;
        } else {
            currentIndex = rootNode.childNodes.length;
            updateImage(nextImageNode);
            currentImageNode = nextImageNode;
        }
    };
    first_btn.onRelease = function() {
        nextImageNode = rootNode.firstChild;
        if (nextImageNode == null) {
            break;
        } else {
            currentIndex = 1;
            updateImage(nextImageNode);
            currentImageNode = nextImageNode;
        }
    };
    Any ideas where i might be going wrong?

    Here's the XML code i'm using:
    PHP Code:
    <?xml version="1.0"?>

    <presentations>
    <presentation>
    <name>Presentation 1</name>
    <Slides>

      <slideNode jpegURL="images/pic_1.swf">Picture 1</slideNode>

      <slideNode jpegURL="images/pic_2.swf">Picture 2</slideNode>

      <slideNode jpegURL="images/pic_3.swf">Picture 3</slideNode>

      <slideNode jpegURL="images/pic_4.swf">Picture 4</slideNode>

      <slideNode jpegURL="images/pic_5.swf">Picture 5</slideNode>

      <slideNode jpegURL="images/pic_6.swf">Picture 6</slideNode>

      <slideNode jpegURL="images/pic_7.swf">Picture 7</slideNode>

      <slideNode jpegURL="images/pic_8.swf">Picture 8</slideNode>

      <slideNode jpegURL="images/pic_9.swf">Picture 9</slideNode>

    </Slides>

    </presentation>

    <presentation>
    <name>Presentation 4</name>
    <Slides>

      <slideNode jpegURL="images/pic_1.swf">Picture 1</slideNode>

      <slideNode jpegURL="images/pic_2.swf">Picture 2</slideNode>

      <slideNode jpegURL="images/pic_3.swf">Picture 3</slideNode>

      <slideNode jpegURL="images/pic_4.swf">Picture 4</slideNode>

      <slideNode jpegURL="images/pic_5.swf">Picture 5</slideNode>

    </Slides>

    </presentation>


    </presentations>
    Regards once again,
    Suzy

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