Welcome, Guest
  • Author Topic: Xml: I'm looking for a simply script to learn  (Read 3698 times)

    abbatg

    • Guest
    Hello,
    i need a simply script to load and disply one node in xml.:
    in Xml just one node:

    <item>shampoo</item>

    what is the code I put in Flash  to load and  display "shampoo"?

    If I would to add  as other node? for esample :
    <Itemnumber>213R<itemnumbe>

    What I change?r


    Thank you
    Best regarda




    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Xml: I'm looking for a simply script to learn
    « Reply #1 on: 12/05/05, 11:35 »
    A newbie FAQ for XML: http://www.huikuri.com/flash/xml/
    Google for Flash-XML tutorials, tons around there.

    jorge

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #2 on: 12/05/05, 12:09 »
    A newbie FAQ for XML: http://www.huikuri.com/flash/xml/
    Google for Flash-XML tutorials, tons around there.

    jorge

    I hate this replay...
    I adked here becouse in google I don't found what I was looking for..
     I need simply code to learn how the data are loaded and display from xml to flash.
    The tutorial you'll find in google  are for expert.

     

    papachan

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 507
      • View Profile
      • Air Flex Developer
    Re: Xml: I'm looking for a simply script to learn
    « Reply #3 on: 12/05/05, 14:11 »
    take a look at Macromedia Help guide, about the XML object but i think your question is elementary, dont be afraid to ask more about your own practice and your doubts.

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Xml: I'm looking for a simply script to learn
    « Reply #4 on: 12/05/05, 14:22 »
    The FAQ is really simple, so begin there.
    Le'ts see a Google Seach for : "Xml flash tutorial"
    Second entry: http://www.actionscript.org/tutorials/intermediate/XML/index.shtml
    Oh, Jesse stratford explain with an XML ... with one node, well, and after that, two nodes.
    Titles: What is XML?, Why and when to use XML?, Loading XML into Flash,  Data from XML within Flash ... uff, lot of stuff
    Is this too much complicated?
    After hate things, take some time to search.

    Jorge

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #5 on: 12/06/05, 03:43 »
    thanks. But this like many example I founfd shows how to load...but How to display  the data?
    for exampla i:
    in this case "trace" if I check by ALT+enter the data are loaded but doesn't showed:
    tuteInfo_xml = new XML();

    tuteInfo_xml.ignoreWhite = true;
    tuteInfo_xml.onLoad = function(success) {
       if (success) {
          trace('Author.xml loaded. Contents are: '+this.toString());
       }
    };

    tuteInfo_xml.load('author.xml');


    Ihow to display it?
    thanks.


    ..:: Mazhar Hasan ::..

    • Mods
    • Systems Administrator
    • *****
    • Posts: 828
    • Cheers
      • View Profile
      • SyedMazharHasan.com
    Re: Xml: I'm looking for a simply script to learn
    « Reply #6 on: 12/06/05, 04:36 »
    Hello Joseph!


    Les say your xmlis like:

    <node>
       blablabla
    </node>
    and if you are loading xml in the xml object say: myXml
    the way your trace out data by using the statment:
          trace('Author.xml loaded. Contents are: '+myXml.toString());

    you can use instead:

       myVariableName ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();
       trace(myVariableName);

    Now you can use this variable anywhere to display the data. Be it a text field or any other thing.
    Your wish is my command

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #7 on: 12/06/05, 08:14 »
    thank but does't work.
    II created the txt dynamic called: ":   myVariableName "

    And I put in the AS script this:
    tuteInfo_xml = new XML();
    tuteInfo_xml.ignoreWhite = true;
    tuteInfo_xml.onLoad = function(success) {
       if (success) {
          myVariableName ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();   trace(myVariableName);
       }
    };


    the txt dynamic  had been ib the same photogram of the script but doesn't work.. :(

    papachan

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 507
      • View Profile
      • Air Flex Developer
    Re: Xml: I'm looking for a simply script to learn
    « Reply #8 on: 12/06/05, 11:45 »
    try:
       if (success) {
          _root.myVariableName ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();   trace(myVariableName);
       }

    or
       if (success) {
          _root.myVariableName.text ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();   trace(myVariableName);
       }

    ..:: Mazhar Hasan ::..

    • Mods
    • Systems Administrator
    • *****
    • Posts: 828
    • Cheers
      • View Profile
      • SyedMazharHasan.com
    Re: Xml: I'm looking for a simply script to learn
    « Reply #9 on: 12/06/05, 16:03 »
    tuteInfo_xml = new XML();
    tuteInfo_xml.ignoreWhite = true;
    tuteInfo_xml.onLoad = function(success) {
       if (success) {
          myVariableName ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString(); trace(myVariableName);
       }
    };


    the txt dynamic had been ib the same photogram of the script but doesn't work.. :(


    Just for confirming, are you using the load keyword for loading xml data, such as: tuteInfo_xml.load("somfile.xml");

    And are you using myVariableName as the instance name of  your dynamic text field or the variable name of your dynamic text field (as the two are very different, you assign instance name in the left side field in the property inspector and the var name in the bottom right part of the property inspector of a dynamic textfield)

    If you are using myVariableName as the instance name, then instead of writng the line::
    myVariableName ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();

    write:

    myVariableName.text ='Author.xml loaded. Contents are: '+ myXml.firstChild.firstChild.toString();
    Your wish is my command

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #10 on: 12/07/05, 03:42 »
    but flash gives this:

    Author.xml loaded. Contents are: undefined

    savneet

    • Seasoned Programmer
    • ***
    • Posts: 156
      • Yahoo Instant Messenger - savneets@yahoo.com
      • View Profile
      • Email
    Re: Xml: I'm looking for a simply script to learn
    « Reply #11 on: 12/07/05, 05:59 »
    Hi,

    I have created the following xml file.
    Code: [Select]
    <names>
     <nodes>savneet</nodes>
     <nodes>Amit</nodes>
    </names>

    and in flash
    Code: [Select]
    var qb_xml:XML=new XML();
    qb_xml.ignoreWhite=true;
    var displayName:String;

    qb_xml.onLoad=function(success)
    {
    if(success)
    {
    displayName="My xml file content "+qb_xml.firstChild.firstChild.firstChild.toString();
    trace(displayName);
    }
    }
    qb_xml.load("test.xml");
    and the outp is  My xml file content savneet

    regards,
    savneet

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #12 on: 12/08/05, 04:11 »
    sorry, nyt what is the name of field dynamictext?
    whitout dybamic   text  allows to show the data...
    regards

    savneet

    • Seasoned Programmer
    • ***
    • Posts: 156
      • Yahoo Instant Messenger - savneets@yahoo.com
      • View Profile
      • Email
    Re: Xml: I'm looking for a simply script to learn
    « Reply #13 on: 12/08/05, 04:26 »
    Hi,
    make the displayName as dynamic text field.

    Regards,
    savneet

    abbatg

    • Guest
    Re: Xml: I'm looking for a simply script to learn
    « Reply #14 on: 12/08/05, 06:59 »
    this is incorrect I think:
    names>
    <nodes>savneet</nodes>
    <nodes>Amit</nodes>
    </names>

    However it doesn't work.
    I tested by ctrl+enter....undefinite


    bho...
     
    bye