A
A
Alexey2010-09-16 14:58:30
Adobe Flash
Alexey, 2010-09-16 14:58:30

How to read/write from Flash to a database (MySQL or MSSQL)

I am planning to write a Flash application that, among other things, will access the database.
Please tell me the best solutions or links to articles on this topic.

Answer the question

In order to leave comments, you need to log in

10 answer(s)
M
mihailt, 2010-09-16
@mihailt

I would recommend looking towards AMF3.
This is the native flash/flex transfer format given.
On the server side, if php then Zend_Amf (http://framework.zend.com/download/amf) or php-amf3 (http://sourceforge.net/projects/php-amf3/), the latter is many times faster if python then pyAMF in conjunction with django, twisted or something else to your taste)) you don’t know about java.

V
verwolfdotss, 2010-09-16
@verwolfdotss

Coldfusion is an Adobe-promoted J2EE-based back-end web application platform.
In fact, to communicate with the database, in any case, you will have to write some kind of server component that processes client requests for swf and performs various operations with the database. In fact, the choice comes down to the programming language with which you are more comfortable working.

J
jcrow, 2010-09-16
@jcrow

"How can a swf object that runs on the client side be able to read/write to a database that is on the server side?" - this is the right question.

L
lehha, 2010-09-16
@lehha

For transport, use HTTP or XML - and wrap the necessary data in them and unpack them on the server side.
A fairly universal approach in any case, given that Flash has direct functions for working over HTTP / XML

V
Vladimir Chernyshev, 2010-09-16
@VolCh

Not a great Flash specialist, but doesn't he have a fairly highly developed means of accessing network services? If all you need to do is to give the application access to the database, then just raise the DBMS on the server's external interfaces (if we are talking about client applications from the central database) or on the local ones (if we are talking about local applications) and contact :) Maybe even for Flash (Actionscript?) There are various adapters that make it easier and abstract to work with the database and, for example, you don’t have to write SQL queries.
But just think, do you really need access to the database or do you need the data that is stored in it and / or the ability to write it, but with additional logic, for example, advanced authentication and authorization? Then you need to introduce a three-tier architecture - client application -> server application -> database

L
lsdima, 2010-09-17
@lsdima

There is already quite a lot and correctly said above. Maybe my experience will be useful. Now in one project I use direct SQL queries from the video, through a php script (in the simplest version - 10 lines of code). The PHP script executes the incoming request and sends the data back to the movie in JSON. I can say that this is a very convenient and simple way: the capabilities of sql queries are completely enough to perform complex selections, extra data does not run between the client and the server. In flash, we get an array or object with the results of the selection. In my sql2flash class, queries look something like this: sql2flash("select * from table", slqHandler), where sqlHandler is the query result handler. If interested, I can send the code.

L
lsdima, 2010-09-18
@lsdima

What does "You can easily get them from there" mean? Especially if they are generated programmatically. Write about it to Adobe.
And what side is the online game here? I wrote above that you need to understand the expediency of such a decision. For example, in this way, data is pulled out from ~ 10 interconnected databases, in which there is exclusively public information. I want to take a look at this monstrosity bike with the API you offer, especially if the data structure can change.
And if you need to get access to secret data, no one bothers to write a separate php script.
And that you are again with this database with passwords, it is closed, closed. Well, if a person does not understand, then not a single tutorial will help him secure the system, especially in the case of such a rather non-trivial solution as flash <--> mysql.

Z
zwie, 2010-09-16
@zwie

garbage-collector.ru/2007/05/assql_actionscript_mysql_driver.html - here is something on this topic. I don’t remember the essence (I’ve read it for a long time), but it seems like working with sockets is happening directly.

R
Robotex, 2010-09-19
@Robotex

Not directly.
But it is implemented very simply, through PHP.
Create an object URLRequest("path_to_PHP_script"). We assign URLVariables to it in data, in which we first enter the data necessary for writing to the database (they may not be there if, for example, we read from the database). Next, we create a URLLoader object and call its load method, into which we pass our URLRequest as a parameter.
The script receives data, works with the database and displays the result via echo.
After that, the COMPLETE event of the URLLoader is fired and the result is in the data field.

S
ssneg, 2011-06-22
@ssneg

The SWF is executed on the client and sends data to the PHP script using the POST (or GET) method. The script receives the data and writes it to the table. I will not write the PHP code, here is what is on the side of the client, AS3:
var loader : URLLoader = new URLLoader();
var request : URLRequest = new URLRequest("www.server.com/somescript.php");
request.method = URLRequestMethod.POST;
var variables : URLVariables = new URLVariables();
variables.peremennaja1 = "value1";
variables.peremennaja2 = "value2";
request.data = variables;
// Handlers
loader.addEventListener(Event.COMPLETE, on_complete);
loader.load(request);
function on_complete(e : Event):void{
trace("Всё послано, шеф!");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question