Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Displaying photos from an XML file

Explorer ,
Aug 26, 2008 Aug 26, 2008
Here's my next little challenge: have to build an app that shows a bunch of photos (listed in an XML file) based upon certain criteria in the XML data. First view will show ALL the photos, and then the user will whittle down the choices/photos based upon criteria they select via check boxes.

I'm sure I can now figure out how to pull the XML data into the application. I'll have to build a listener for the check box component(s), which shouldn't be difficult. The onClick event would then have to search through the XML/array and show only the user-selected data. It would be good also if the pictures were actually pulled from the server's hard drive rather than having them stored in the Flash file. That would allow the site's owner to easily add images by simply copying them to the server and adding data to the XML. Is that do-able, and if so, can anyone put me on the right path (theorhetically) to developing it?

The other question I have at this pre-planning stage is this: ALL the pix are certainly not going to fit on the stage at one time. I am going to have to have a finite number of pix, say six, visible on the stage, and then allow the user to filter through the as-yet-unseen images by clicking on a number (Page 2 of 7), or something along those lines.

Before I get too deep into the project, can anyone give me some theory on how something like that might be accomplished? I'm trying to kinda map this one out in my head prior to getting knee deep in code.

Thanks!
TOPICS
ActionScript
424
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 02, 2008 Sep 02, 2008
In your xml you should add "description tags" to the pic's main tag. Example:
<xml>
<pictures>
<pic name:"Picture 1">city</pic>
</pictures>

When the user chooses his criteria, have an "if" statement check if that pic (which has been assigned to a variable) includes the criteria (if (my_variable.text == "city") or something similar). If it does then display the picture and if not, then don't display it. The more check boxes you include the (possibly) more complex and number of "if" statements.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2008 Sep 03, 2008
LATEST
Hey Nick,

For the pulling the pics from the server part, just have the XML reside on the server along with the images and point your flash app to http://servername/mypics.xml

The XML can contain relative links to the pictures

<myxml>
<pic>
<location>/images/mypic.jpg</location>
<description>fancy house</description>
<etc...></...etc>
</pic>
</myxml>

As for the determining how many pages of pics you have,
once you load the XML into and XMLList object (you've done this before), you can search through, get the number of pics, etc.

So you'll have to build your app like:

var pageCount = 1;

for(var i=0;i<myXML.pic.length;i++){
if(i%6==0){
pageCount++;
}
}

Hope that helps!

Cheers,
FlashTastic

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