A Flash Developer Resource Site


FreeSpin3D – 3D in a Flash. Real-Time 3D for Developers and Designers.


Turn Flash in Desktop App or Widget. Win & Mac.


Create Flash animations without coding with FlashEff


World's Favorite Flash Tool 200,000 users and growing!


Speed, agility, flexibility - The HP BladeSystem c-Class.

Storage Networking , Part 1
eBook: A storage network is any network that's designed to transport block-level storage protocols. But understanding the ins and outs of networked storage takes you deep into several of protocols. This guide covers SANs, Fibre Channels, Disk Arrays, Fabric, and IP Storage. »

Storage Networking 2, Configuration and Planning
eBook: Picking up where Part 1 left off, Part 2 of our look at storage networking examines configurations for SAN-attached servers and disk arrays, and also includes a look at the future of IP storage. »

Storage Management Costs in the Enterprise: A Comparison of Mid-Range Array Solutions
Whitepaper: Many factors contribute to the ownership cost for enterprise storage. These include (but are not limited to): physical capacity relative to physical space requirements, performance capacity for data transfer and system reaction time, software maintenance and updates, expandability and flexibility, and much more. »

Storage Is Changing Fast  Be Ready or Be Left Behind
PDF: The storage landscape is headed for dramatic change, thanks to new technologies like Fibre Channel over Ethernet (FCoE), pNFS, object-based storage and SAS that will affect everything from NAS and SANs to disk drives. Get the knowledge you need to make the most of your storage environment, now and in the future. »

HP StorageWorks EVA4400
Demo: Dont settle for an expensive and complex array that lacks functionality. The HP StorageWorks EVA4400 delivers virtual storage with enterprise class functionality at an affordable price. »

Featured Flash FLA
Gallery Downloads 11189 Flash Movies | 7 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Flash Crazy
» Title: Paper Plane 2
» Description: The movie is an animation of a paper plane.
» More by Flash Crazy


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6615 Flash Sites | 8 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: zCube Web Design Port Folio
» Comments: zCube WebDesign Studios. The online portfolio of zCube By Singaporean web designer Zizhong.


Random Links | Add your own Flash Related Links
Flash Tutorials 1170 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create Graduation Photo Slideshow to Cherish School Memories
» Making movieclips point at the mouse
» Create Flash slideshow for Youtube
» Move a sprite with the keyboard
» Convert FLV to AVI video with DIVX codec to author a desired video with your favorite FLV movie!
» Flash Video Conversion Guide for Apple TV
» How to Convert FLV to iPhone movies
» Convert FLV(Flash Video) video to Cell Phone
» Convert FLV to AVI with XviD video codec to enjoy a DVD quality video with half of its size
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Web Developer
Aquent
US-CO-Denver

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Dynamic_Content

Categories Integrating Flash and mySQL
Author: Vin | Website: http://www.nostamprequired.com |

 
Page 1
1

This tutorial makes use of the PHPObject code which can be found at: http://ghostwire.com/resources/phpobject/

Please download the PHPObject and try out the sample to better understand what's going on here.

This is just a basic tutorial on how to display data in a mySQL database in flash quickly and easily. You can develop this code further to create dynamic Flash movies that feed off a mySQL database. In this example I'm using an eCard project I'm working on. The code will connect to my database to get the card information (the to, from, and message) and display this data in the flash movie. Also note that you should have dynamic text fields named as each of the variables your want to display in your flash movie

The Flash Code:

#include "PHPObject.as"

tmp = new PHPObject();
tmp.setDefaultGatewayKey("secret"); // CHANGE THIS TO WHATEVER SECRET KEY YOU SET IN Gateway.php
tmp.setDefaultGatewayUrl("http://www.yourdomain.com/pathto/Gateway.php"); // CHANGE THIS TO WHERE YOU PLACE Gateway.php
delete tmp;

myFoo = new PHPObject("cards"); // declare a new object and link it to a remote PHP class


// set up responder
myFoo.getcard_onResult = function(result) {

id.text = result[0];
sid.text = result[1];
s_name.text = result[2];
s_email.text = result[3];
r_name.text = result[4];
r_email.text = result[5];
message.text = result[6];
card.text = result[7];
uniqueid.text = result[8];
beenread.text = result[9];
}

// invoke method
myFoo.getcard("rJ7WP605");

So what we're doing is setting up the Gateway to the PHP file first. Then we set up the code in Flash to get the array PHP will return to us and to put each part of the array into seperate input text boxes on in the flash movie. The invoke method starts the process. It calls the php file "cards.php" as specified in the PHPObject function. Now we have to write the PHP to get the database info and return it to flash.

The PHP Code (cards.php):

<?

class cards {
function getcard($getcard) {

$db_name = "yourdbname";
$connection = @mysql_connect("localhost", "username", "password") or die("Cound not connect to database");
mysql_select_db($db_name, $connection) or die("Count not select database");
$query = "SELECT * FROM ecards WHERE sid LIKE '$getcard'";
$q_result = mysql_query($query);
return mysql_fetch_row($q_result);

}
}

?>

This is just some basic PHP code to connect to a mySQL database and return the results. The getcard() function requires a parameter in this example. This parameter tells mySQL which record it wants to pull. In this case it's the id of the card. Once the SQL query has been run, we just send the row as an array and let flash parse it. You can manipulate the data however you want in the PHP, then just have Flash display it.

1

» Level Intermediate

Added: : 2003-05-12
Rating: 6.65 Votes: 57
Hits: 87
» Author
Young Web Developer trying to learn the latest technologies and apply them to practical projects. I'm looking for a job, email me.
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers