A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simpler XML?

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Location
    Kent, OH
    Posts
    9

    Simpler XML?

    Okay, so the last post I put up was apparently a real poser, I'll ask a related question.

    To access a node attribute in flash, we have to enter a string something along the lines of:

    listItems(this.firstChild);
    listItems(this.firstChild.nextSibling);
    listItems(this.firstChild.nextSibling[2]);

    Which can be quite a bit of code in the case of a listing of states and countries from an xml like:

    US>
    AL Title="Alabama" URL="http://Alabama"/>
    AK Title="Alaska" URL="http://Alaska"/>
    AR Title="Arkansas" URL="http://Arkansas"/>
    AZ Title="Arizona" URL="http://Arizona"/>
    /US>

    EURO>
    X Title="" URL="http://"/>
    /EURO>

    The intuitive naming of nodes in xml is great, but why do we then have to refer to them as lines and lines of:

    listItems(this.firstChild.nextSibling[45]);
    listItems(this.firstChild.nextSibling[46]);
    listItems(this.firstChild.nextSibling[47]); ?

    Can't we just say something like:

    listItems(this.US.AL);
    listItems(this.US.AK);
    listItems(this.US.AR); and so on, using those intuitive node names?

    I'm putting the node attributes into variables for a world map, lotsa states and countries.

    Thanks!
    Jeffery Wright
    Planetfall Studios

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112
    There are shortcuts... use the attribute name 'id', and give the node a value that is unique among all of the other nodes. You can then refer to it that way.

    See this thread:
    http://www.flashkit.com/board/showth...hreadid=297324
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

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