Falcon! What a grand code name ;-).
Here is the Falcon ZIP file with instructions and samples.
Falcon is a custom class that wraps the Adobe Flash ActionScript 3 five data classes normally used to access a server script or system such as PHP, Perl, Ruby, ASP, etc. and then of course on to databases like MySQL, SQL Server, etc. It makes it so that you do not have to worry about the URLVariables, URLRequest, URLRequestMethod, URLLoader and URLLoaderDataFormat code.
You pass the following parameters to the Falcon AS3 data class:
- the URL to your server script, text, binary data or XML File
- an optional type of data – Falcon.VARIABLES, TEXT, BINARY or XML_DATA
- an optional data object that holds variables to send to the server
You set an Event.COMPLETE listener to call a function. The event object’s target has three properties. A Boolean error property, a data property and if you use the FalconProvider class there is a dataProvider property:
1. The error property (eventObject.target.error) will be true if connection to the server fails and false if it succeeds.
2. The data property (eventObject.target.data) holds the variables, text, binary or XML that comes back from the server:
- Variables – if your server script sends age=23 and you ask for data.age then you get 23
- Text – for example from a text file just use myTextField.text = data;
- Binary – this is your binary feed (actually untested but should work)
- XML – this a Flash XML object representing the XML from the server
3. Note there are two classes you can use – Falcon and FalconProvider. In FalconProvider, the dataProvider property (eventObject.target.dataProvider) is provided in the variables case when the variables come back in some sort of sequence like name1, age1, name2, age2, etc. FalconProvider automatically provides a DataProvider object with columns of name, age, etc. You can use this for a DataGrid or if you use label1, data1, label2, data2 then you can use it for a List or ComboBox. You must have a component that uses the DataProvider (DataGrid, List, etc.) in the library of your FLA if you use the FalconProvider class.
4. Please note that if you use the default Falcon.VARIABLES, then your server script such as PHP must return at least one key/value pair – in the following format variable=value&variable2=value. So in a simple example – status=complete. You cannot have any lines above your <?PHP either otherwise the new line characters cause problems.
5. If you want to avoid caching issues, put a random number on the end of your script call like so: somefile.php?rand=”+Math.random().
Falcon was created by Inventor Dan Zen. You may use the code as you wish and if possible a credit link to this site will help make the world an easier place ;-). If you are interested in learning to make classes like this or other aspects of interactive multimedia please visit the Sheridan Interactive Multimedia blog for information about its one year post grad college program. Thank you to all at Adobe for such great tools and for our wonderful Flash user group, FITO in Toronto.
-30-
Filed under: Press Release Tagged: | class, cs3, data, Falcon, flash, URLLoader, URLLoaderDataFormat, URLRequest, URLRequestMethod, URLVariables











Great Class! Thanks for making life easier!
Can’t wait to use Falcon. The world is a better place with more falcons flying around. No Seagulls I hope, especially from 1963.
Thanks for the class. This will come in very handy. Just an FYI, your examples are throwing errors right out of the box. Like the FalconXML example, you have your parameters in the wrong order.
Thanks Marcus – changed around the parameter order and forgot to update the XML example. Cheers. All fixed in the current ZIP – clear your cache if you are downloading again – but it was just that parameter order change – or get rid of that null when calling Falcon from the XML example.
The variable examples will give errors until you set up the PHP and database…
I love this – it is a wonderful and clean method to working with MySql.
Is there any chance of more lessons and examples? It would be great to see ways of deleting and editing tables, etc.
Great stuff!
Good idea RL. We will try and get to it in a few weeks. That would help designers that want to provide functionality beyond just storing and presenting.
Hi Dan
Thanks for your response – I think you have the beginnings of something great here.
Falcon inspires me, but your photos move me – you have some wonderful things going on there.
Hi Dan
I have been struggling in trying to get the Falcon to delete and update tables… any ideas?
Regards
Paul
Do you mean tables on the database? And do you mean delete records and update records in the table? Or do you mean the DataGrid on the Flash side? Most likely the tables in the database…
You can send information to PHP for instance from Falcon like so – up top you would declare an object for sending variables:
Then when you have variables to send you store them as properties on this object like so:
Then when you create the Falcon instance you pass along this object and these variables get sent to PHP:
In PHP you would access the variables like so:
Then you can update the score in the table by assigning your database connection to $db for instance and writing something like:
This would update the score in the table.
You could delete a record in the table like so:
I will in a week or two write some more examples that make this work. Hopefully I have understood your question and that this will get you under way. You are given a database example in the zip so the rest of the stuff is there and then you would make these changes…
Dan
Hi,
How can i pass url inside flash right now i am creating text file with php code and pass text file inside flash but i guess it will not good approach if many people try to access the same link is there a way by which i can load url from outside .
for example
http://www.abc.com?month=1
thanks
umer
Sorry Umer – missed your question until now… this is not a Falcon question so I will only describe how to do it as opposed to doing it because I am short on time. You can collect the query string on the end of a URL using the JavaScript property location.search and then pass this into Flash by document.write() of the Flash object code and inserting the variable and value as the value of a FlashVars property. You collect the FlashVars in Flash via the loaderInfo.parameters.variablename. Not terribly simple I am afraid but certainly doable. You can do something similar in PHP for instance too.
[...] Press Release [...]
Great Job !!!
Thanks !