dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Using a string Array instead of an Flash XML object?

  1. #1
    Member
    Join Date
    Apr 2003
    Location
    detroit, mi usa
    Posts
    53

    Using a string Array instead of an Flash XML object?

    Flashkit,

    The scenario is this. I have a small project that
    loads XML into a Flash MX movie from two external XML
    docs, BookStuff.xml and BookStuff.dtd You can see the
    tags from these two docs below in this message.

    I would like to stop using these external files and
    build the Flash XML object from a string Array
    instead. Do you know if it is possible to build a
    Flash XML object from an Array? I would like to parse
    this Array and rebuild the XML object just as it was
    when building it from the external files. Should I be
    able to drop the .dtd file entirely and have the Array
    method work?

    To say the least I am having much difficulty doing
    this I wish for an expert’s opinion.

    Thanks,
    - Jimmy

    <!------------------------------------------>
    BookStuff.xml
    <!------------------------------------------>
    <?xml version = "1.0"?>
    <BookStuff xmlns:BookStuff = "BookStuff.dtd">

    <Topic>
    <Name>Topic One</Name>
    <Chapter>Chapter One</Chapter>
    <ImageURL>ch1tp1.swf</ImageURL>

    </Topic>

    <Topic>
    <Name>Topic Two</Name>
    <Chapter>Chapter One</Chapter>
    <ImageURL>ch1tp2.swf</ImageURL>
    </Topic>

    <Topic>
    <Name>Topic Three</Name>
    <Chapter>Chapter One</Chapter>
    <ImageURL>ch1tp3.swf</ImageURL>
    </Topic>

    <Topic>
    <Name>Topic One</Name>
    <Chapter>Chapter Two</Chapter>
    <ImageURL>ch2tp1.swf</ImageURL>
    </Topic>

    <Topic>
    <Name>Topic Two</Name>
    <Chapter>Chapter Two</Chapter>
    <ImageURL>ch2tp2.swf</ImageURL>
    </Topic>

    <Topic>
    <Name>Topic One</Name>
    <Chapter>Chapter Three</Chapter>
    <ImageURL>ch3tp1.swf</ImageURL>
    </Topic>


    </BookStuff>

    <!------------------------------------------>
    BookStuff.dtd
    <!------------------------------------------>
    <!DOCTYPE BookStuff [
    <!ELEMENT BookStuff (Topic*)>
    <!ELEMENT Topic (Name, Chapter, ImageURL)>
    <!ELEMENT Name (#PCDATA)>
    <!ELEMENT Chapter (#PCDATA)>
    <!ELEMENT ImageURL (#PCDATA)>
    ]>

  2. #2
    Member
    Join Date
    Apr 2003
    Location
    detroit, mi usa
    Posts
    53

    a string Array instead of an Flash XML object? (follow up)

    It seems the XML tags I included in the message above were parsed by the browser. I have attached them in the following .txt file.

    Thanks again,
    - Jimmy
    Attached Files Attached Files

  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Jimmy,

    I am a little confused as to where you are trying to remove the XML and replace it with an array.

    Are you trying to change how the data is inputted into Flash, or are you talking about converting the XML documents to an Array inside flash?

    Or are you talking about your output files?

    Btw if you put your XML in [ PHP] [ /PHP] tags it will display correctly.

    Thanks

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

  4. #4
    Member
    Join Date
    Apr 2003
    Location
    detroit, mi usa
    Posts
    53

    Replace using the external XML

    Hey Luke,

    What I am trying to do is just replace using the external XML without having to change all the Flash XML Objects and parsing that is in the actionscript code already.

    Originally the project loaded the XML from an external file, now I am trying to use javascript to populate a variable within the Flash movie with the exact number of tags and content as the original XML file had, in the same format as well. The thought is so I can just pass all these tags in a string and then recreate them as the Flash XML Objects to work with all of the existing actionscript code.

    Does this help explain?
    - Jimmy

  5. #5
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Ok,

    Now I understand. Yes it would be possible to do. I am not sure about in Flash MX and later but the flash parser was all written in flash (which is why when the internal string manipulation routines where optimised flash sped up incredibly, 10x speed increase), so everything that the original parser can do you should be able to recreate with the flash objects.

    Have a look through the API documents and you should have all the bits you will need to recreate the XML document. Probably the main methods you would want are:

    XML.appendChild, XML.createElement, XML.createTextNode.

    Basically use a createElement, or createTextNode and then append that object using XML.appendChild.

    Attributes are really easy, just use:

    xmlNode.Attributes.newAttr = "bleh"

    and the attribute will be created for you.

    For more details go here:

    http://www.macromedia.com/support/fl...ionary827.html
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  6. #6
    Member
    Join Date
    Apr 2003
    Location
    detroit, mi usa
    Posts
    53

    string.split() method

    Hey Luke,

    This is the start I needed, thank you! Also I've experimented some and have found a way to recreate the XML array of nodes by just using the string.split() method. It is working very well.

    - Jimmy

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