Falcon Challenge! Is there a simpler way to get data from a database into a DataGrid in Flash?

CHALLENGE!

Here is the code required to get data from a MySQL database result in PHP into a DataGrid on stage in Flash. Below is script.php:

<?PHP
   $db = mysql_connect("yourServer", "yourUserName", "yourPassword");
   mysql_select_db("yourDatabase",$db);

   include_once("falconize.php");  // in same directory
   echo falconize(mysql_query("SELECT * FROM yourTable",$db)); 
?> 

In Flash with DataGrid on stage:

   // in package
   import com.danzen.utilities.FalconProvider;

   // in constructor or some other method
   var myFalcon:FalconProvider = new FalconProvider("script.php");
   myFalcon.addEventListener(Event.COMPLETE, function(e:Event) {
      myGrid.dataProvider = e.target.dataProvider;
   });

We could be wrong, but is this the shortest number of lines around? Let us know if you find a challenger! Download the new falcon.zip for the added falconize.php file.

Dan Zen

-2010-

FalconProvider Correction

An update has been made to FalconProvider in the Falcon Zip. Thanks to Kasper Kamperman saving the lonely single-result return. Please update your FalconProvider files and recompile any swf’s that use it.

Falcon Flash Launches to Help Designers and Developers Pass Data Between Flash and Server Scripts

falconSample

Falcon Flash at http://falconflash.wordpress.com is the first of the Flash Feather series of advanced interface classes in Flash to launch.  With over one thousand downloads we are pleased that it has been helpful.  It really is a simple wrapper class for the five data classes in Flash.  It lets you easily read text and XML or send variables to and from server scripts like PHP.

var myFalcon:Falcon = new Falcon("yourfile.php or .xml or .txt");
myFalcon.addEventListener(Event.COMPLETE, getData);
function getData(e:Event) {
    trace (myFalcon.data.yourVariable);
    // or just myFalcon.data for XML or txt
}

Flash Feathers is located at http://flashfeathers.wordpress.com and through the links at the right.  Flash Feathers features the following open source solutions:

FLASH FEATHERS

  • ROBIN – multiuser chat and realtime game classes with Flash and PHP
  • FALCON – easy data transfer between Flash and server scripts
  • HUMMINGBIRD – parallax effect with mouse movement for 3D menus
  • GOOSE – multitouch emulator and processor with just Flash and Browsers
  • PENGUIN – tilt emulator and processor for tilt and translation apps
  • WOODPECKER – sound frequency and wave animation for MP3 and FLV
  • GOOSE – motion capture so a cursor follows your Web cam motion
  • DODO – blob detection to provide blobs anywhere there is Web cam motion

The Falcon Download ZIP file is at left.  There is a standard way to install all the Flash Feathers classes as detailed in the readme.txt file and the various class files and goes like follows:

INSTALLATION

  • create a classes/ folder somewhere generic on your harddrive
  • add the classes folder to your Flash Class Path – in the Flash Menu:
  • choose Edit > Preferences > ActionScript – ActionScript 3 Settings
  • use the + sign for the source path box to add the path to your classes/ folder
  • put the provided com/ folder in your classes/ folder

This way your classes from Flash Feathers will all work together along with other people’s distributed classes.  DO NOT add the com/ folder to your class path in the Flash preferences!  Read above if this is not clear.

Please have a look at the VIDEO page and the sample CODE page for more information about Falcon.  You can download the code through the link at the left on http://falconflash.wordpress.com.

FRIENDS AND DONATIONS
Please let us know if you use Falcon and we will add you to the Friends area at left.  If you use Falcon for a commercial venture and would care to donate that would be super!

karmatja

FEATHERS
Falcon is one of a selection of open source solutions called Flash Feathers available at http://flashfeathers.wordpress.com.

feathers

Dan Zen

-09-

Follow

Get every new post delivered to your Inbox.