xml multiple arrays

  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

First post on these forums so go easy please!

I am stuck on making a photo viewer, currently I am sourcing from a text file with array_1=001.jpg,002.jpg&array_2.jpg=003.jpg,004.jpg etc

the arrays are then selectable through this function

Code: [ Select ]
function select(q) {
    //create array
    thumb_array = new Array();
    
    //load array from text file
    loadArray = new LoadVars();
    loadArray.load("array.txt");
    
    //evaluate if text file has loaded
    loadArray.onLoad = function(success) {
        
        
if (success) {
ab = this["array_"+q];
thumb_array = ab.split(",");
_root.image_array = thumb_array;
posthumbs();
        }
    };
}
  1. function select(q) {
  2.     //create array
  3.     thumb_array = new Array();
  4.     
  5.     //load array from text file
  6.     loadArray = new LoadVars();
  7.     loadArray.load("array.txt");
  8.     
  9.     //evaluate if text file has loaded
  10.     loadArray.onLoad = function(success) {
  11.         
  12.         
  13. if (success) {
  14. ab = this["array_"+q];
  15. thumb_array = ab.split(",");
  16. _root.image_array = thumb_array;
  17. posthumbs();
  18.         }
  19.     };
  20. }


triggered in turn by this button action:

Code: [ Select ]
bt1.onRelease = function() {
dragwindow.scrll.select(1);
};
  1. bt1.onRelease = function() {
  2. dragwindow.scrll.select(1);
  3. };

I have tried to replicate this in xml but not too sure how to go about it can anyone offer any advice please?

Many thanks in advance.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • rynoe
  • Banned
  • Banned
  • User avatar
  • Posts: 17

Post 3+ Months Ago

How many photos are there?
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

There are probably around 600 photos, which I need to split up into approximately 8 different categories.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

This will load an XML list (formating shown later) that will contain an attribute telling the photos catagory, and the URL to the pic. Once loaded it will seporate the adresses into catagory arrays.
Code: [ Select ]
photoXML = new XML();
photoXML.ignoreWhite = true;
photoXML.load("photolist.xml");
photoXML.onLoad = function () {
    catagory1 = new Array();
    catagory2 = new Array();
    for (var j = 0; j<photoXML.firstChild.childNodes.length; j++) {
        if(photoXML.firstChild.childNodes[j].attributes.catagory == "1"){
            catagory1[catagory1.length] = photoXML.firstChild.childNodes[j].firstChild.nodeValue;
        }
        if(photoXML.firstChild.childNodes[j].attributes.catagory == "2"){
            catagory2[catagory2.length] = photoXML.firstChild.childNodes[j].firstChild.nodeValue;
        }
    }
}
  1. photoXML = new XML();
  2. photoXML.ignoreWhite = true;
  3. photoXML.load("photolist.xml");
  4. photoXML.onLoad = function () {
  5.     catagory1 = new Array();
  6.     catagory2 = new Array();
  7.     for (var j = 0; j<photoXML.firstChild.childNodes.length; j++) {
  8.         if(photoXML.firstChild.childNodes[j].attributes.catagory == "1"){
  9.             catagory1[catagory1.length] = photoXML.firstChild.childNodes[j].firstChild.nodeValue;
  10.         }
  11.         if(photoXML.firstChild.childNodes[j].attributes.catagory == "2"){
  12.             catagory2[catagory2.length] = photoXML.firstChild.childNodes[j].firstChild.nodeValue;
  13.         }
  14.     }
  15. }


Here is an example of what the list looks like,
Code: [ Select ]
<photos>
    <pic catagory="1"><![CDATA[directory/sub-directory/pic.jpg]]></pic>
    <pic catagory="2"><![CDATA[directory/sub-directory/pic.jpg]]></pic>
</photos>
  1. <photos>
  2.     <pic catagory="1"><![CDATA[directory/sub-directory/pic.jpg]]></pic>
  3.     <pic catagory="2"><![CDATA[directory/sub-directory/pic.jpg]]></pic>
  4. </photos>


Where <pic catagory="#"> is the attribute for the catagory to put that photo in & <![CDATA[directory/sub-directory/pic.jpg]]> is the URL to the photo. Note the italics, you need change ONLY the italics for the URL, leaving out the <![CDATA[ ]]> will cause problems. :D
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

thanks for your reply, trying to work my way through this but having trouble. Rather than trying to explain everything it is probably easier if you see the files

The rough .swf file with the text as the source is here:
http://neelam.port5.com/dd/gallery/bigthumb5.swf

and the .fla file is here:
http://neelam.port5.com/dd/gallery/bigthumb5.fla

At the moment the thumbnails are loaded from the text source
(http://neelam.port5.com/dd/gallery/array.txt)
and dynamically resized in Flash, however I think this causes a lot of load time as they are essentially the same k as the full sized pics (most of the pic loading and other magic happens in the "scroll" movie).

I would ideally like the xml to be something like this:

Code: [ Select ]
<?xml version="1.0" encoding="UTF-8"?>
<gallery path="/">

<country name="Australia">
    <image title="auspic1" source= "001.jpg" thumbsrc="001.jpg" whatever="info1"/>
</country>

<country name="New Zealand">
    <image title="nzpic1" source="002.jpg" thumbsrc="002.jpg" whatever="nzinfo1"/>
    <image title="nzpic2" source="003.jpg" thumbsrc="003.jpg" whatever="nzinfo2"/>
    </country>

</gallery>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <gallery path="/">
  3. <country name="Australia">
  4.     <image title="auspic1" source= "001.jpg" thumbsrc="001.jpg" whatever="info1"/>
  5. </country>
  6. <country name="New Zealand">
  7.     <image title="nzpic1" source="002.jpg" thumbsrc="002.jpg" whatever="nzinfo1"/>
  8.     <image title="nzpic2" source="003.jpg" thumbsrc="003.jpg" whatever="nzinfo2"/>
  9.     </country>
  10. </gallery>


so I can include image information as attributes for each picture along with loading the photo itself into a movie clip (will probably be clearer if you see the files).

So is it possible to set up an array (country) that can be selected by a button, which then loads in the relevant thumbnails. In turn when you click on the thumbnail could it load the corresponding full sized picture into the containerMC movie clip.

Sorry for so many questions, but I am still grappling furiously with learning all this against the clock, and you seem to have a good grasp on the subject.

I've started trying to set up the XML part in the actionscript, but it just seems to become a mess! Thanks again for any help.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

please use code tags when posting, thanks. :)
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

Apologies Unflux, new to these forums - found that option now, thanks for setting me straight.

btw I saw your Photoshop battle against Canadiaguy on the kirupa forums, absolutely awesome work it has to be said.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

no worries mate. Thanks for the compliment, it was defintiely a great
battle. I hope CG can get to finish it off soon. :D
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

his work is awesome too, a very close battle.

Do you have any insights into my flash/xml problem, it is slowly but surely driving me further round the bend :shock:
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

ok, so now I have this, trying to replicate the select function in XML:

Code: [ Select ]
function select(q) {
    
    var gallery_xml = new XML();
    gallery_xml.ignoreWhite = true;
    gallery_xml.onLoad = function(success) {
    if (success) {
        var gallery = this.firstChild;
        for(var i=0; i<gallery.childNodes.length; i++){
        
        tArray[q] = gallery.childNodes[i].attributes.name;
            thumb_array = new Array();
            for(j=0;j<gallery.childNodes[i].childNodes.length;j++){    
            thumb_array[j] = gallery.childNodes[i].childNodes[j].attributes.source;
            }
            
        ab = tArray[q];    
            //trace (ab);
        _root.image_array = thumb_array;
        trace (thumb_array);
        // loading first picture
        containerMC.loadPic(0);
}    
    }

    else {
        title_txt.text = "Error!";
    }
};
gallery_xml.load("gallery.xml");
  1. function select(q) {
  2.     
  3.     var gallery_xml = new XML();
  4.     gallery_xml.ignoreWhite = true;
  5.     gallery_xml.onLoad = function(success) {
  6.     if (success) {
  7.         var gallery = this.firstChild;
  8.         for(var i=0; i<gallery.childNodes.length; i++){
  9.         
  10.         tArray[q] = gallery.childNodes[i].attributes.name;
  11.             thumb_array = new Array();
  12.             for(j=0;j<gallery.childNodes[i].childNodes.length;j++){    
  13.             thumb_array[j] = gallery.childNodes[i].childNodes[j].attributes.source;
  14.             }
  15.             
  16.         ab = tArray[q];    
  17.             //trace (ab);
  18.         _root.image_array = thumb_array;
  19.         trace (thumb_array);
  20.         // loading first picture
  21.         containerMC.loadPic(0);
  22. }    
  23.     }
  24.     else {
  25.         title_txt.text = "Error!";
  26.     }
  27. };
  28. gallery_xml.load("gallery.xml");


with this as the trigger

Code: [ Select ]
bt1.onRelease = function() {
//    this.enabled = 0;
//    bt2.enabled = 1;
    dragwindow.scrll.select(1);
};
  1. bt1.onRelease = function() {
  2. //    this.enabled = 0;
  3. //    bt2.enabled = 1;
  4.     dragwindow.scrll.select(1);
  5. };


this is the xml I am using

Code: [ Select ]
<?xml version="1.0" encoding="UTF-8"?>
<gallery path="/">

<country name="Australia">
    <image title="auspic1" source= "001" thumbsrc="001" whatever="info1"/>
</country>

<country name="New Zealand">
    <image title="nzpic1" source="002" thumbsrc="002.jpg" whatever="nzinfo1"/>
    <image title="nzpic2" source="003" thumbsrc="003.jpg" whatever="nzinfo2"/>
    <image title="nzpic2" source="005" thumbsrc="003.jpg" whatever="nzinfo2"/>
    <image title="nzpic2" source="006" thumbsrc="003.jpg" whatever="nzinfo2"/>
    <image title="nzpic2" source="008" thumbsrc="003.jpg" whatever="nzinfo2"/>
</country>

</gallery>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <gallery path="/">
  3. <country name="Australia">
  4.     <image title="auspic1" source= "001" thumbsrc="001" whatever="info1"/>
  5. </country>
  6. <country name="New Zealand">
  7.     <image title="nzpic1" source="002" thumbsrc="002.jpg" whatever="nzinfo1"/>
  8.     <image title="nzpic2" source="003" thumbsrc="003.jpg" whatever="nzinfo2"/>
  9.     <image title="nzpic2" source="005" thumbsrc="003.jpg" whatever="nzinfo2"/>
  10.     <image title="nzpic2" source="006" thumbsrc="003.jpg" whatever="nzinfo2"/>
  11.     <image title="nzpic2" source="008" thumbsrc="003.jpg" whatever="nzinfo2"/>
  12. </country>
  13. </gallery>


it loads the thumbnails as I want it to but only after pressing the 'trigger' button twice and it loads all the images (from country = Australia and country = New Zealand).

Can anyone straighten it out for me so the select function works with the different arrays.

the . fla is here:
http://neelam.port5.com/dd/gallery/bigthumb6.fla

Would be most grateful for assistance
  • ex-hippo
  • Newbie
  • Newbie
  • ex-hippo
  • Posts: 7

Post 3+ Months Ago

got it sorted, anyone interested in the answer should check here:

http://www.kirupaforum.com/forums/showt ... post527899

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.