Need help in ActionScript 3.0

Discussion in 'Programming' started by gerta, Jan 5, 2009.

  1. #1
    I've made a gallery with AS 3.0 but I've a problem the thumbnails of photos aren't displayed at the flash gallery. I think the problem is in this part of code :
    imageGallery.load("gallery.xml");
    function parseGalleries():Void {
    if (imageGallery.firstChild.nodeName == "gallery") {
    var rootNode:XMLNode = imageGallery.firstChild;
    for (i=0; i<rootNode.childNodes.length; i++)
    {
    if (rootNode.childNodes[i].nodeName == "category") 
    {
    currentGallery = rootNode.childNodes[i];
    for (j=0; j<currentGallery.childNodes.length; j++) 
    {
    curobject=currentGallery.childNodes[j].firstChild.nodeValue;
    if (curobject.nodeName == "object")
    {
    currentObject = curobject;
    object.push(currentObject);
    
    if (curobject.firstChild.nodeName == "description")
    {
    currentDescription = curobject.firstChild.nodeValue;
    descriptions.push(currentDescription);
    
    	current_Thumbnail = curobject.firstChild.nextSibling.nodeValue;
              thumb_path.push(current_Thumbnail);							   
    
    	currentPhoto=curobject.lastChild.nodeValue;
        photo_path.push(currentPhoto)
    }
    }
    }
    Code (markup):
    and the xml file is smth like this :
    <?xml version="1.0"?>
    <gallery>
    <category title="agencies" intro="intro 1">
    <object title="object1">
    <description>description 1</description>
    <thumbnail_path>photo/thumbs/agencies/conad.jpg</thumbnail_path>
    <photo_path>photo/agencies/conad.jpg</photo_path></object></category>
    <category title="bars" intro="test 2">
    <object title="object">
    <description>description test 2</description>
    <thumbnail_path>photo/thumbs/bars/145067.jpg</thumbnail_path>
    <photo_path>photo/bars/145067.jpg</photo_path></object></category>
    </gallery>
    Code (markup):
    How can I access the description,photo_path and thumbnail_path in the right way, cause I alway get messages: "undefined" when I try to access them with the code above.
     
    gerta, Jan 5, 2009 IP
  2. wassim

    wassim Well-Known Member

    Messages:
    322
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    110
    #2
    This doesn't look like AS3 for me, it's more of AS2, if you are using AS3 then you would be much better off using XMLList to parse the XML.
     
    wassim, Jan 6, 2009 IP