A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: As3 & xml

  1. #1
    Senior Member vevmesteren's Avatar
    Join Date
    Sep 2001
    Location
    Montréal, Québec
    Posts
    566

    As3 & xml

    I have been toying around with the following:

    I successfully load the following XML into my Flash as ticketsData:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <ScratchTickets xmlns="http://tempuri.org/">
          <encryptedEmailAddress>string</encryptedEmailAddress>
          <Tickets>
            <Ticket>
              <TicketID>int</TicketID>
              <PrizeTypeID>int</PrizeTypeID>
            </Ticket>
            <Ticket>
              <TicketID>int</TicketID>
              <PrizeTypeID>int</PrizeTypeID>
            </Ticket>
          </Tickets>
        </ScratchTickets>
      </soap:Body>
    </soap:Envelope>
    I am trying to access my Tickets. But I am failing so far.

    I tried:
    code:
    trace('Tickets: '+ticketsData.ScratchTickets.Tickets[0].TicketID);


    I get:
    Code:
    TypeError: Error #1010: A term is undefined and has no properties.
    at com.game.tickets::Ticketsdata/readdata()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    when I run this:
    code:
    trace('Tickets: '+ticketsData.ScratchTickets);



    I get this:
    Code:
    Tickets:
    How can I get access to the list of <Tickets> ?

    Help...

    V
    it is your mind that decides - it is with your mind that you fly


    vevmedia

  2. #2
    Member
    Join Date
    Mar 2009
    Location
    Brooklyn, NY
    Posts
    77
    It looks like you're skipping over the Ticket node. What happens if you try:

    trace('Tickets: '+ticketsData.ScratchTickets.Tickets[0]. Ticket.TicketID);

  3. #3
    Senior Member vevmesteren's Avatar
    Join Date
    Sep 2001
    Location
    Montréal, Québec
    Posts
    566
    Already tried that
    Code:
    TypeError: Error #1010: A term is undefined and has no properties.
    	at com.game.tickets::Ticketsdata/readdata()
    	at flash.events::EventDispatcher/dispatchEventFunction()
    	at flash.events::EventDispatcher/dispatchEvent()
    	at flash.net::URLLoader/onComplete()
    it is your mind that decides - it is with your mind that you fly


    vevmedia

  4. #4
    Member
    Join Date
    Mar 2009
    Location
    Brooklyn, NY
    Posts
    77
    Can you post the code you're using to load the xml?

  5. #5
    Senior Member vevmesteren's Avatar
    Join Date
    Sep 2001
    Location
    Montréal, Québec
    Posts
    566
    The XML loads perfectly fine, when I trace(ticketsData) I get the XML seen above...
    it is your mind that decides - it is with your mind that you fly


    vevmedia

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    There are nodes between the root and ScratchTickets, so the child operator (".") doesn't work. You can use the descendant operator (".."), which should work.

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