A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: xml vs txt

  1. #1
    Member
    Join Date
    Mar 2002
    Location
    Montana, Bulgaria
    Posts
    37

    xml vs txt

    i want to ask a litle question ... well i`m not familiar with XML ... but i`m using flash from a year and a half ... and i was wondering what does XML do more than a .txt file .... what is the diference to flash ?? i`m looking forward to studiing XML but i can`t see what`s the use of it ... ? can i store data from flash into the .xml file or do i need .txt too ?
    10nk you in advance ... please excuse me for the bad gramarr

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    The biggest thing for me is that XML allows you to structure your data.

    for example if you have a bookstore with data about books and you set it up like this:

    PHP Code:
    <books>
      <
    book>
        <
    author>Bill Bloggs</author>
      <
    book>
    <
    books
    If you wanted to have multiple authors it is a simple matter of adding extra authors like this:

    PHP Code:
    <books>
      <
    book>
        <
    author>Bill Bloggs</author>
        <
    author>Bill Bloggs Brother</author>
      <
    book>
    <
    books
    Now where XML really comes into its own is when you want to expand your service. (the X in XML stands for Extensible).

    Say you want to add a ISBN number to your book details. Unfortunately you are going to have to change the backend before you can change your flash file. With a text file unless you were really clever with your initial coding you would have to rewrite your flash file at exactly the same time.

    However with XML you can add the ISBN:

    PHP Code:
    <books>
      <
    book isbn="0-13-027363-5">
        <
    author>Bill Bloggs</author>
        <
    author>Bill Bloggs Brother</author>
      <
    book>
    <
    books
    And your existing code will keep working without a problem. In fact you have to go out of your way to make problems when the XML changes. With a little bit of care, changing the XML to this:

    PHP Code:
    <books>
      <
    book isbn="0-13-027363-5">
        <
    author>Bill Bloggs</author>
        <
    author>Bill Bloggs Brother</author>
        <
    chapters>
          <
    chapter name="Introduction" pages="2"/>
           <
    chapter name="In the beggining" pages="37"/>
        </
    chapters>
        <
    index pages="8" />
        <
    tables>
          <
    table name="Figure 1"/>
          <
    table name="Figure 2"/>
        </
    tables>
      <
    book>
    <
    books
    Would still work perfectly fine in your original app. You wouldn't necessarily see the new information but your application would still work fine.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Member
    Join Date
    Mar 2002
    Location
    Montana, Bulgaria
    Posts
    37
    well... looks impresive ... but lets say ... i need to add very litle information ... for example a small cinema program ... 2 small variables once a week ... something like this ...

    1. xmen2 - 15.06.2003

    that`s the info i need to add once a week ... but i need the date and the text to be apart ... and i need to store the data somewhere (i was thinking of .txt) will i need php to load the data from the txt or only to save to the txt ... meaning ... Flash-> ? ->TXT
    and then .... TXT-> ? ->Flash.
    i`m sorry for the lame questions but i`m not fomiliar with php,cgi,MySQL or other server side scripting languages or data bases.... and i was searching for something that can compensate the php so i dont need to study it ... i thought xml can come in php`s place but it seems i was wrong ... thank you anyway

  4. #4
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    Nono, sadly, its hard to find out how-to this on the web, fortunately, if u have some cash, and there's a Chapters bookstore near you, I suggest buying the "Flash MX Bible", it's made for beginners that already know Flash MX, but want to venture further into XML. But anyways, the reason why Im saying its hard to explain in here, is because you need to see how the XML in structured in the Flash doc (in 2 places), and then text file. Thats like 2-3 different areas you need to add XML in order to get a working flash/xml application. Now to answer your question about what you can exactly do with XML & Flash, is that not only does XML make data for flash movies structured, its also made a industry in itself for building various web services, data tickers, and most importantly, Flash with XML User Interfacees which is a pretty bold & very anticipated feature in Flash MX

    Oh and lastly, if you already know HTML and are a newcomer into XML, don't sweat it ! XML will remind you of HTML, but XML goes on much stricter rules, but while it is an extensible language, that means you can invent your own tags,(unlike HTML where u have predefined tags u need to use) which gives a whole new level of developer capabilities. Its good stuff ! Just takes a little time to understand.
    Last edited by TRJNET; 06-28-2003 at 12:25 PM.
    consultant / contractor / designer

  5. #5
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    "that`s the info i need to add once a week ... but i need the date and the text to be apart ... and i need to store the data somewhere (i was thinking of .txt) will i need php to load the data from the txt or only to save to the txt ... meaning ... Flash-> ? ->TXT
    and then .... TXT-> ? ->Flash.
    i`m sorry for the lame questions but i`m not fomiliar with php,cgi,MySQL or other server side scripting languages or data bases.... and i was searching for something that can compensate the php so i dont need to study it ... i thought xml can come in php`s place but it seems i was wrong ... thank you anyway"


    You can store & load data by 2 ways, 1st way is by actionscripting, which is really the "LoadVars" function to load data to a movie, but you can even be more dynamic by using XML to implement data, either way, you don't neccesarily need a server-side script, like cgi,php etc. Basic data loading only needs the desiger to know how-to code using ActionScripting or XML coding knowledge. If it was like that where people needed to have a script, I think that people would be using XML & also LoadVars a lot less. All a sccript is for is to relay data from a remote server, as you know, with Flash 6 movies, you can only load movies from your own server, and not remotely due to secuirty reasons, thats why people use proxy scripts on the remote server in order to retreieve remote data.
    consultant / contractor / designer

  6. #6
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    Originally posted by tupps


    Say you want to add a ISBN number to your book details. Unfortunately you are going to have to change the backend before you can change your flash file. With a text file unless you were really clever with your initial coding you would have to rewrite your flash file at exactly the same time.

    However with XML you can add the ISBN:

    PHP Code:
    <books>
      <
    book isbn="0-13-027363-5">
        <
    author>Bill Bloggs</author>
        <
    author>Bill Bloggs Brother</author>
      <
    book>
    <
    books
    And your existing code will keep working without a problem. In fact you have to go out of your way to make problems when the XML changes. With a little bit of care, changing the XML to this:

    PHP Code:
    <books>
      <
    book isbn="0-13-027363-5">
        <
    author>Bill Bloggs</author>
        <
    author>Bill Bloggs Brother</author>
        <
    chapters>
          <
    chapter name="Introduction" pages="2"/>
           <
    chapter name="In the beggining" pages="37"/>
        </
    chapters>
        <
    index pages="8" />
        <
    tables>
          <
    table name="Figure 1"/>
          <
    table name="Figure 2"/>
        </
    tables>
      <
    book>
    <
    books
    Would still work perfectly fine in your original app. You wouldn't necessarily see the new information but your application would still work fine.

    Thanks

    Luke [/B]
    k, so what would the XML coding in the textfile would look like ? You just got me interested in this ISBN stuff Seems quite useful if you are creating flash news or media content based on a dating-system !
    consultant / contractor / designer

  7. #7
    Member
    Join Date
    Mar 2002
    Location
    Montana, Bulgaria
    Posts
    37
    well... i got nowsy about xml and i downloaded some tutorials from here ... and i found a very simple ang clean xml->flash tutorial ... very nice ... but ! The xml is easy ... i got how it works ... but the actionscript bothers me ... i`ll show you what i`m meaning ...
    (very sorry if it`s not 100% like the original but i dont have flash instaled on the PC i`m writing this reply .. i`m memorizing what i`ve remembered from the script..)
    PHP Code:
    //this is the xml
    <animal>
        <
    type>dog</type>
        <
    name>harry</name>
        <
    sex>male</sex>
    </
    animal
    the addresing to the childe nodes bothers me in flash ... it looked like this ...
    PHP Code:
    MyVar=MyLoadedXml.firstChild.firstChild.firstChild.nameNode 
    thats the adresing to ... <type>dog</type> !(MyVar is set to "dog")
    can you tell me and easier way to adress the nodes loaded from the xml in flash ... if not ... why is firstChild typed 3 tymes ?
    i`ll be very happy if someone can help mi with adressing the xml nodes in flash ...

    p.s.
    i saw in the tutorials a tutorial where you save a xml via php ... is that a good way to proside ?

  8. #8
    Member
    Join Date
    Mar 2002
    Location
    Montana, Bulgaria
    Posts
    37
    and another thing ... i have FlashMX Actionscript (by Derek franklin) ... translated in my home language offcourse .. there is a litle info about xml ... but they dont say why does somethig type this way ... just say how it types ...

    p.s.
    and there`s a litle info about Flash->xml->asp ... but here we dont use asp ... can someone guide me how can i save ... Flash->Xml->MySQL .. and back ... (i think it`s called xml socket .. not static xml)
    10x in advance ...

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