Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 2 of 2
  1. #1

    Question Load PHP Results into Flash

    Hi, im making a flash app that allows users to seach a database using PHP. got this to work great. my next step is to display icons on a map relevent to the search, for example if i search for "bars" icons will appear on the map containing the search results from the php.
    My real question is, how can i get flash to make a dynamic movieclip to represent all the results returned from the search, for each result in the loop?

    Thanks

    Gvp16

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2

    Default

    Back-end language do you use, you always need to output a name/value pair. Here's our PHP script:
    $connect = mysql_connect("localhost", "root", "root");
    mysql_select_db("anastasio", $connect);
    $result = mysql_query("SELECT Title, Comments, Image FROM titles");
    $cant = 0;
    while($row=mysql_fetch_array($result)){
    echo "Title$cant=$row[Title]&Comments$cant=$row[Comments]&Image$cant=$row[Image]&";
    $cant++;
    }
    echo "cant=$cant";
    lash script is almost the same as the text example, with just a little different: the file to load. This is the script for loading the PHP data using previous examples layout:
    //Create the URLLOader instance
    var myLoader:URLLoader = new URLLoader()
    //the data will come as URL-encoded variables
    myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
    //Load using an URLRequest, even beeing local
    myLoader.load(new URLRequest("anastasio.php"))
    //onLoad handler listener
    myLoader.addEventListener(Event.COMPLETE, onDataLoad)
    //add a listener for the complete event
    function onDataLoad(evt:Event){
    for(var i:uint=0; i<evt.target.data.cant; i++){
    this["Title_txt"+i].htmlText = "<b>"+evt.target.data["Title"+i]+"</b>"
    this["Comments_txt"+i].text = evt.target.data["Comments"+i]
    var loader:Loader = new Loader()
    this["holder_mc"+i].addChild(loader)
    loader.load(new URLRequest(evt.target.data["Image"+i]))
    }
    }

    And what's the difference with the text example m Well, just the URL to load .
    myLoader.load(new URLRequest("anastasio2.txt"))

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial