A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [AS3]How do i generate xml in php and load in flash?

  1. #1
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766

    [AS3]How do i generate xml in php and load in flash?

    I want to read info from my database in xml format into flash using as3, via php? Can anyone please guide me on how to achieve this?

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    This should give you something to start with:
    http://visualflowdesigns.com/2008/04...-an-sql-query/
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    I am currently using the following codes, but it isn't working, any idea?

    PHP CODE:-
    Code:
    <?php
    header("content-type: text/xml");
    
    $output="";
    
    $output='<Books>'."\n";
    $output.='<Book ISBN=123456>'."\n";
    $output.='<Title>Kulu Manali</Title>'."\n";
    $output.="<Author>Me Me</Author>\n";
    $output.="</Book>\n";
    $output.="<Book ISBN=542631>\n";
    $output.="<Title>Ghost Buster</Title>\n";
    $output.="<Author>Unknown</Author>\n";
    $output.="</Book>\n";
    $output.="<Book ISBN=654312>\n";
    $output.="<Title>Inu Yasha</Title>\n";
    $output.="<Author>My Favourite</Author>\n";
    $output.="</Book>\n";
    $output.="</Books>";
    
    echo "<xmp>".$output."</xmp>";
    ?>

    FLASH Code:
    Code:
    import flash.text.*;
    import flash.events.*;
    import flash.display.*;
    import flash.xml.*;
    import flash.net.*;
    
    
    xml_txt.text="Handling Request";
    
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest("interface_php/xmltest.php"));
    function LoadXML(e:Event):void
    {
    	xmlData = new XML(e.target.data);
    	xml_txt.text=xmlData;
    }

    xml_txt is a dynamic textbox on stage, and it, when run, shows only "Handling Request", nothing else! Any idea or suggetions?

  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    One thing I am noticing is that you did not put quote marks around your attributes <Book ISBN=542631> should be <Book ISBN='542631'>. In XML all attributes have to be in quote marks regardless of the type. Also, I do not think you actually need the \n unless you are doing that for some specific reason I am not aware of.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  5. #5
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    yeh you are right about the qoutes.....and i tried without \n, but without it, there is formatting error! Anyway, thanks for solving my problem!

  6. #6
    Member
    Join Date
    May 2008
    Posts
    49
    use amfphp. I have a great polling script in as2 and 3, but truthfuly this protocol is way better for any use... Im currently using it in a mutliplayer turn based game im developing.

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