dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Appending XML with Flash & PHP

  1. #21
    Senior Member
    Join Date
    Aug 2007
    Posts
    291
    Remember, this is using a server technology that can only be tested on a server that supports PHP. I'll see if I can get around to uploading the file later today.

  2. #22
    Junior Member
    Join Date
    Oct 2009
    Posts
    10

    resolved

    Quote Originally Posted by Taidaishar View Post
    Remember, this is using a server technology that can only be tested on a server that supports PHP. I'll see if I can get around to uploading the file later today.

    yeh.. i upload the php files to my server and i assigned the path /// the problem is with the components i have to use..for example which component shud i use to upload the mp3 file ?

    and to edit the xml... shall i put a text field ? these are my few questions..thats y im asking u for the fla file

    Thanks in advance !

  3. #23
    Senior Member
    Join Date
    Aug 2007
    Posts
    291

    problem...

    I can't find the file... my work laptop just recently crashed and I had a backup, BUT the backup was made BEFORE I made this file.... so now I've lost it... which is bad news for me AND you.

    I'll see if I can give you a bit more explanation through a bit more commenting:
    PHP Code:

    // Set the URL for the PHP uploader scripts
    var myUrl:URLRequest = new URLRequest("writeit2.php");
    var 
    url2:URLRequest = new URLRequest("putFile.php");


    //reads in the current XML document in order to add to it
    function readXML():void
    {
        
    //xmlText.text = "reading xml file";
        
    var vers:* = new Date().getTime();
        
        var 
    myLoader:URLLoader = new URLLoader();
        
        
    myLoader.addEventListener(Event.COMPLETExmlLoaded);

        
    myLoader.load(new URLRequest(path+"songs.xml"));
    };


    // Function that fires off when the user presses the "done" btn... begins the process of uploading the MP3 file
    function uploadVars(e:MouseEvent):void
    {
        
    //mcSermonsPage is just a movieclip that contained all my components, text fields and OTHER movie clips.
        
        //mcBlocker is just a movieclip that covers up the preloader until someone hits the done button
        
    mcSermonsPage.mcBlocker.visible false;
        
        
    fileRef.upload(url2);
        
        
    //btnDone is a button that starts the upload process and this makes it invisible once it's clicked
        
    mcSermonsPage.btnDone.visible false;
        
    readXML();
    }


    //called when the current XML document is loaded and ready for addition
    function xmlLoaded(e:Event):void
    {
        
    //This runs if you're uploading a file for the first time... otherwise it skips it so as not to overwrite data previously added to the XML file
        
    if(runCount <= 1)
        {
            
    myXML = new XML(e.target.data);
            list = new 
    XMLList(myXML);
        }
        
        var 
    node:XMLNode = new XMLNode(1"song")
        
        var 
    urlNode:XMLNode = new XMLNode(1"url");
        
    //txtFilename is an input text field that contains the "URL" data that is to be appended onto the XML file
    var urlText:XMLNode = new XMLNode(3"sermons/"+mcSermonsPage.txtFilename.text)
        
    urlNode.appendChild(urlText);
        
    node.appendChild(urlNode)

        var 
    preacherNode:XMLNode = new XMLNode(1"preacher");
        
    //txtSpeaker is an input text field that contains the "preacher" data that is to be appended onto the XML file
        
    var preacherText:XMLNode = new XMLNode(3mcSermonsPage.txtSpeaker.text)
        
    preacherNode.appendChild(preacherText);
        
    node.appendChild(preacherNode)

        var 
    dateNode:XMLNode = new XMLNode(1"date");
        
    //txtDate is an input text field that contains the "date" data that is to be appended onto the XML file
        
    var dateText:XMLNode = new XMLNode(3mcSermonsPage.txtDate.text)
        
    dateNode.appendChild(dateText);
        
    node.appendChild(dateNode)

        var 
    titleNode:XMLNode = new XMLNode(1"title");
        
    //txtTitle is an input text field that contains the "title" data that is to be appended onto the XML file
        
    var titleText:XMLNode = new XMLNode(3mcSermonsPage.txtTitle.text)
        
    titleNode.appendChild(titleText);
        
    node.appendChild(titleNode)

    //fyi, all of the text fields mentioned previously were on the mcSermonsPage movie clip
        
        
    list.appendChild(node);

    };

    // Function that fires off when the MP3 File is selected from PC and Browse dialogue box closes
    function syncVariables(e:Event):void
    {
        
    //txtFilename is a textbox that holds the filename of the file chosen in the browse box (fileref)
        
    mcSermonsPage.txtFilename.text "" fileRef.name;
        
    mcSermonsPage.btnDone.visible true;

        
    //mcProgress is a movie clip used for a preloader
        
    mcSermonsPage.mcProgress.width 1;

        var 
    variables:URLVariables = new URLVariables();
        
    variables.body myXML;
        
    url2.data variables;
        
    url2.method URLRequestMethod.POST;
    }

    // Function that fires off when the upload of the MP3 file is complete... this function uploads the XML
    function completeHandler(e:Event):void
    {
        
    myUrl.method URLRequestMethod.POST;
        
    myUrl.data myXML;
        
    myUrl.contentType "text/xml";
        
        var 
    xmlLoader:URLLoader = new URLLoader();
        
    xmlLoader.load(myUrl);

        
    xmlLoader.addEventListener(ProgressEvent.PROGRESSxmlProgress);


  4. #24
    Junior Member
    Join Date
    Oct 2009
    Posts
    10

    Lightbulb Erros :S

    got sum erros..working on them... !
    Last edited by g2gayan; 11-04-2009 at 03:34 AM. Reason: zz

  5. #25
    Junior Member
    Join Date
    Oct 2009
    Posts
    10

    Angry

    @ Taidaishar
    Thanks !
    Last edited by g2gayan; 11-04-2009 at 03:33 AM. Reason: my stupidity

  6. #26
    Senior Member
    Join Date
    Aug 2007
    Posts
    291
    I didn't think about decompiling the SWF file. Yeah, I'll zip it up and attach it in a few minutes.

  7. #27
    Junior Member
    Join Date
    Oct 2009
    Posts
    10

    Thumbs up zzzzz

    thanks alot sir i got the swf
    Last edited by g2gayan; 11-04-2009 at 03:33 AM. Reason: zzzz

  8. #28
    PHP Code:
        if(runCount <= 1
        { 
            
    myXML = new XML(e.target.data); 
            list = new 
    XMLList(myXML); 
        } 
    where did you define runcount?

  9. #29
    also I'm getting a

    1120: Access of undefined property myXML. " myUrl.data = myXML; "

    and were
    myXML = new XML(e.target.data);
    list = new XMLList(myXML);

    defined somewhere else?

    i changed it to

    var myXML = new XML(e.target.data);
    var list = new XMLList(myXML);

    but havent been able to test because of that error.

    Could anyone help?

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