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-
Advertisement
Filed under: Analysis, Update Tagged: | adobe, challenge, datagrid, Falcon, falconprovider, flash, MySQL, php










To pass variables to the server script means adjusting the FalconProvider call as follows:
new FalconProvider(“script.php”, FalconProvider.VARIABLES, {var1=”hello”, var2=7});
I’ve found a bug in the FalconProvider.as
When I have only one result getData doesn’t give back this result. Because with one result, the variable “max” stays 0, while there is actually one result.
This data displays correctly :
error=&f0=1%5F1285258235%5F2%2Ejpg&f1=1%5F1285236942%5F8%2Ejpg&total=2
This data is not displayed while it should :
error=&f0=1%5F1285258235%5F2%2Ejpg&total=1
I’ve changed : if(max>0)
to : if (prefix)
Oops – thanks. Have made the corrections, will post the fix and announce. Thank you for pointing it out.
Well… a year and about 6,000 views has gone by and there have been no challenges… anybody?
Hey, i was wandering whether falcon can be used to send and save variables into a database in a standalone flash application (as3), if this is possible could you please help me in doing this in an application I’m currently building.
Thanks, John
Sorry about the delay – somehow missed this comment. It depends perhaps what you mean by a standalone application. Yes, it can bring in text but where is your database for the standalone application – if it is AIR and you are still going over the Web then yes. If it is a local SQLLite or something then I think probably not as you access the database right from Flash rather than a server script.
Hey Dan,
You can make it even shorter by adding an optional callback to the constructor!
e.g. new FalconProvider(“script.php”, function () { /* Set Data Provider */ });
Yes – you are right – just thought we should keep the traditional AS event system ;-). How’s it going Raz!