Solved

Flash: how to display results of data query - SQL vs. XML (or other)?

Posted on 2010-09-09
4
445 Views
Last Modified: 2013-11-11
I am trying to create a flash Banner Advertisement that will use a database to create a ZIP Code locator. This advertisement will likely get a lot of hits so I need a very efficient solution.

The banner ad will let the user input a ZIP Code into a form field which, when submitted, will query a database to find matching data (i.e. store information) and then display the results in the flash banner file.

I *think* I can do this using an XML file (i.e. instead of querying a database, query the XML file) However, with 20,000+ ZIP Codes and related data nodes, this could be a HUGE XML file - and I'm not 100% positive it is possible.

Is it possible to query a database directly? I suspect so but my concern here is that the banner ad will get tons of hits and strain the database.

Has anybody done something like this before?

What is the best solution?!
0
Comment
Question by:bearclaws75
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Jakob_E earned 300 total points
Comment Utility
Hi,

20,000 nodes of 5-50 characters each will result in a 150-450 KB XML file (you don't want that ;-)

I would do something like this:


// Function that submits the user input to the data base - that
// after processing returns XML containing just enough info
function submitToDB():void{
   
    // Loader and listener
    var loader:URLLoader=new URLLoader()
        loader.addEventListener(Event.COMPLETE,resultFromDBHandler,flase,0,true)
   
    // Request and request method (GET/POST)
    var request:URLRequest=new URLRequest("http://www.domain.com/getZipInfo.php")
        request.method=URLRequestMethod.POST;
   
    // Variables and values
    var vars:URLVariables
        vars.zipCodeInput="10007" // Replace with user input
       
    // Add variables to the request and load
    request.data=vars
    loader.load(request)
}


// Function to handle the XML returned
function resutlFromDBHandler(e:Event):void{
    var xml:XML=new XML(e.data)
    // do other stuff here
}





Best,
Jakob E



0
 
LVL 9

Expert Comment

by:Jakob_E
Comment Utility
Second function should be resultFromDBHandler not resutl..

 
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 200 total points
Comment Utility
Agree with above that you can go through PHP.  Here is a reference to support that using Flex.

http://cookbooks.adobe.com/post_Simple_MySQL_to_Flex-5561.html
0
 

Author Closing Comment

by:bearclaws75
Comment Utility
Thanks. This is exactly what I was looking for.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Creating and Managing Databases with phpMyAdmin in cPanel.
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now