Bryan,

>Is it possible to INSERT or UPDATE MySQL data directly from flash,
>whether or not PHP is used too?
>
>For example, I want an embedded flash application, and based on what a
>user selects in that application, it automatically UPDATES a MySQL table.
>
>P.S. I know this is solely a PHP group, and sorry if this topic is too
>off-topic, but it may involve some PHP along the way...
I wouldn't know if it is possible directly from Flash (guess not) but it is
not a good ID to allow. As James already pointed out: any Flash app runs on
the client machine. To enable any flash app to do anything with your MySQL
database you will need to give that client machine direct access to your DB.
So if this is not an intranet application: you will need to give the whole
world direct access to your database. Bad idea.

Rather, use a PHP layer in between, which is very easy to do. The PHP app
accesses the database and passes data to and from the Flash app. You can use
session variables to control access just as you would with other scripted
pages (i.e.: allow access only to for instance logged in users).
Have a look at "GetURL" and "loadVariables" actionscript commands; these are
the commands you will use for calling your PHP.
You will need to do extensive actionscripting inside your Flash movie, and
actionscript is not that friendly for importing arrays (you will have to
pass a long string and break it up rather than being able to pass an array)
but other than that no big secrets.

Also, you can not trust the speed of response of your PHP script (say your
flash runs at 12 frames per second. You can not bet on the PHP script to
have returned all data say 4 frames after the call, so you will have to make
some type of data-aquisition movie clip run independently inside the flash
movie. This will test for some variable (say: results_complete to have
become true (set it false when requesting data by means of the
loadVariables, and then make sure the last thing your script does is send
'&results_complete=true&' back to the flash movie) and only then allow the
Flash movie to continue.

Just go playing a bit, it is rather fun to have interactive movies running
on a site (and besides: including a flash movie is great for streaming music
and playing it inside a site).

Marc

Reply via email to