dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Pull in xml correctly?

  1. #1
    Member
    Join Date
    May 2004
    Location
    Georgia
    Posts
    39

    Pull in xml correctly?

    So I'm new to xml. By trial and error, I'm able to get xml to show up in my fields, but think there may be a shortcut that t&e won't get me to. XML structure is like this:

    PHP Code:
    <gallery>
    <
    album id="stills">
    <
    img src="img1.jpg" title="Image 1 Title" caption="Description for 1 " />
    <
    img src="img2.jpg" title="Image 2 Title" caption="Description for 2 " />
    <
    img src="img3.jpg" title="Image 3 Title" caption="Description for 3 " />
    </
    album>
    </
    gallery
    I am loading one image per frame. On image 1's frame I have:
    Code:
    title_txt.text = xml.firstChild.firstChild.firstChild.attributes.title;
    caption_txt.text = xml.firstChild.firstChild.firstChild.attributes.caption;
    On image 2's frame I have:
    Code:
    title_txt.text = xml.firstChild.firstChild.firstChild.nextSibling.attributes.title;
    caption_txt.text = xml.firstChild.firstChild.firstChild.nextSibling.attributes.caption;
    On image 3's frame I have:
    Code:
    title_txt.text = xml.firstChild.firstChild.firstChild.nextSibling.nextSibling.attributes.title;
    caption_txt.text = xml.firstChild.firstChild.firstChild.nextSibling.nextSibling.attributes.caption;
    Etc.
    Based on the xml alone and not the programming structure of my movie ( ), is there a way to condense the statements (as opposed to repeating nextSibling ten times) as I move along in the frames and number of images?

    Thanks in advance.

    Matt
    Last edited by metallicamatt; 05-18-2007 at 12:59 PM.

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I'm for anyone trying to learn

    To me...dedicating a frame to each display is inefficient and not needed. You can do the same in a single frame using buttons to bounce through your entires and push the values to the same textfields.

    I just did a file for another guy attached in this thread:

    http://board.flashkit.com/board/showthread.php?t=731560

    That might show what I mean. In that example it uses text nodes (whereas you use node attributes) but It's basically the same ides just would need small alteration for your type to accommodate their attribute style.

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