In order for this tutorial to work, you need to make sure that your environment is setup by following the instructions located here. I have included an fla (cs3) file in the /Flash folder of the Flex project archive. You would not normally do this for a production project but this is just meant to be a simple example and since they both use the same php files it didnt make much sense to split this article up into two separate articles.
I am currently using Flex Builder 3.0.2 and Flash CS4 but I saved the fla as a cs3 file for those that don’t have it yet.
Code and instructions after the jump
zendDbFlex.zip (859.8 KiB, 26 hits)
- The first thing you are going to want to do is download the file and import the project into Flex using File > Import > Flex Project > Archive File.
- After that is done you will want to create a database called zenddbflex using PHPMyAdmin.
- Run the sql script ‘Table.sql.txt’ located in the sql folder of the Flex project against your zenddbflex database to create the products table.
- Create a folder under your ‘wamp\www directory’ called ‘zendDbFlex.’
- Copy the gateway.php file and the ZendData.php file from the ‘php’ folder in your flex project into the ‘wamp\www\zendDbFlex’ folder you just created above.
- In ZendData.php, modify this line to change the user/password if you are using a different combination
mysql_connect("localhost","root","");.
- Run the Flex project or the fla file in Flash and you should see 4 products output into the text area!
I realize I skipped some steps by not talking about db creation etc in PHPMyAdmin but there are plenty of tutorials on that. If you do have any questions or I missed a step, please comment below.