A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Creating a form in Flash to edit XML

  1. #1
    Member
    Join Date
    Jan 2010
    Location
    Drobeta Turnu Severin
    Posts
    59

    Creating a form in Flash to edit XML

    Hello. I'm in an urgent need of help.
    I have 2 XML files 1.XML and 2.XML which contains the following:
    1.XML
    Code:
    <scans1>
         <documents1>
              <set1>
    <![CDATA[
    <a href="menu/1.pdf" target="_blank">Document1</a>
    <a href="menu/2.pdf" target="_blank">Document2</a>]]>
              </set1>
         </documents1>
         <documents2>
              <set2>
    <![CDATA[
    <a href="menu/3.pdf" target="_blank">Misc1</a>
    <a href="menu/4.pdf" target="_blank">Misc2</a>
    <a href="menu/5.pdf" target="_blank">Misc3</a>]]>
              </set2>
         </documents2>
    </scans1>
    2.XML
    Code:
    <scans1>
         <documents1>
              <set1>
    <![CDATA[
    <a href="menu/6.pdf" target="_blank">John</a>
    <a href="menu/7.pdf" target="_blank">David</a>
    <a href="menu/8.pdf" target="_blank">Max</a>]]>
              </set1>
         </documents1>
         <documents2>
              <set2>
    <![CDATA[
    <a href="menu/9.pdf" target="_blank">Default1</a>
    <a href="menu/10.pdf" target="_blank">Default2</a>]]>
              </set2>
         </documents2>
    </scans1>
    My problem is not how to import CDATA in Flash. That is already loaded.
    I need to know if there is a way to create a form in Flash with a "add new line" button, document name field and document description link field.
    I was thinking that adding a new line would add smth like:
    Code:
    <![CDATA[
    <a href="menu/6.pdf" target="_blank">John</a>
    <a href="menu/7.pdf" target="_blank">David</a>
    <a href="menu/8.pdf" target="_blank">Max</a>
    <a href="menu/xxxxxx.xxx" target="_blank">yyyyy</a>]]>
    And the 2 txt fields from the form use a find and replace event.... or smth...
    Is the first time I'm playing with adding lines inside CDATA tag and really I cannot sleep at night.... searched through internet for similar things and in AS2.0 I found nothing.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    at the end of each a href tag, use this: \n or \r or \r\n

    that is if you're loading the text into a dynamic text field, and it that it's displaying HTML!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Flash doesnt really have the ability to build/save XML files..

    you'd need to handle tis on the PHP/server side end..

    or..

    import yoru XML data into FLASH.. and break it down..edit..and re-export/save back to php script for saving.


    hereis a SUPER old example I did long ago..

    a store front..(demo.. Proof of Concept).. that is powered by an XML file..
    http://dmstudios.net/demos/PMS/

    I then made a little ADMIN panel in FLASH/PHP to handle the updating of the 'store front' (so to speak).. ie: upload the images needed..as well as actually save the .xml file on the server again..for later, updated, use.

    Admin Panel:
    http://dmstudios.net/demos/PMS/admin.html


    Now.. if you DO NOT truly want to edit/alter the XML.. and only edit/alter the textfields/display of this XML...

    then its alot more simple.

  4. #4
    Member
    Join Date
    Jul 2011
    Posts
    51
    @whispers: Your demo of PMS is awesome. Could you please provide the source? Or could you please show the server side code example and the xml data structure? I am little stuck in similar type of application. You might give a better way to do. As the demo looks very nice in functionality. I also need to know the billing gateway methods from AS2, PHP. Please help.



    FFA

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    hi..Im not even sure where the source is currently.. (this is serioulsy YEARS & YEARS old!)

    but you load the XML data into flash..so its really just a big string... and you can edit/add as you wish..

    then you send the whole text string to a php script to save it (as Flash can NOT create text/xml files..etc)


    as far as 'billing' I just export the needed info to PayPal using the Web Checkout Standard API..

  6. #6
    Member
    Join Date
    Jul 2011
    Posts
    51
    As this demo is working, could you please provide the php and the xml part? I mean to say the server side code. So, I can understand what I have to do in Flash. Please PM the code.



    FFA

  7. #7
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    why do you want that? (especially the .xml?) as it would only be proprietary to code/fla you dont have. :|

    the php script is simpel save .txt file type

    <?

    $xmlData=$_POST["xmlData"];
    $fp = fopen ("path/to/filename.xml", "w");

    if($fp)
    { fwrite($fp,stripslashes("$xmlData"));
    fclose($fp);
    echo ("&returnMessage=OK");
    } else {
    echo ("&returnMessage=NOT OK");
    }

    ?>

  8. #8
    Member
    Join Date
    Jul 2011
    Posts
    51
    I want to know how to format or phrase raw data from flash and save into xml and then again read that data from xml and display into flash. What I want to know, is in what format you are sending data to php to phrase and write to xml. and how is the final xml looks like?. I don't need your fla to understand how you did that in flash. I am just trying to know the server side thing to handle from flash. Is it a right way if I pass a String to php with separator? And phrase it to save in xml format. What is the data format you are passing from flash? and how the xml file looks after saving data?



    FFA
    Last edited by FlexFlashApps; 10-19-2011 at 03:35 PM.

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I send a 'string' from Flash..

    but this string is really formatted XML... just sent as a string to a php script.

    php script does nothing but save the .xml file.. (not formatting or editing on the side of php)

    I make my initial XML source by hand.. read it all into Flash.. so basically I have all nodes/elements..etc....

    I parse the data into an ARRAY.. (if I remember correctly) LOL

    then I edit/alter anything I want..

    when I want to save/export.. I run through my Array(s) and build back p the same XML format.. (but with new values/data).. and send to PHP to save on the server as an .xml file my flash app uses for its source data.

  10. #10
    Member
    Join Date
    Jul 2011
    Posts
    51
    Thank you whispers. It is really helpful to me. Only thing is the xml structure.

    Thank you again.



    FFA

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