Flash
  Home arrow Flash arrow Page 3 - Building Data-Driven Flash Movies
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Building Data-Driven Flash Movies
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 71
    2002-07-23


    Table of Contents:
  • Building Data-Driven Flash Movies
  • Message In A Bottle
  • No Hands
  • No News Is Good News
  • Alien Invasion
  • What's On The Menu?
  • Splitting Up
  • Linkzone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building Data-Driven Flash Movies - No Hands
    ( Page 3 of 8 )

    Obviously, that was a very primitive example, though one that did demonstrate the concept of integrating data from an external source with a Flash movie. Now, how about a twist?

    Let's suppose I modify the Flash file above so that the call to loadVariables() loads variables from a server-side script ("message.php"), rather than a static text file.

    loadVariablesNum ("http://localhost/message.php", 0);
    This "message.php" script contains code to retrieve a message (either from a database or other data source) and output it in the format Flash needs. Here's what the script looks like:

    <? // message.php // open connection to database $connection = mysql_connect("localhost", "root", "secret") or die ("Unable to connect!"); mysql_select_db("data") or die ("Unable to select database!"); // formulate and execute query $query = "SELECT message FROM message_table"; $result = mysql_query($query) or die("Error in query: " . mysql_error()); // get row $row = mysql_fetch_object($result); // print output as form-encoded data echo "msg=" . urlencode($row->FirstName); // close connection mysql_close($connection); ?>
    This should be fairly simple to understand, even if you've never programmed in PHP before. Very simply, I'm opening a connection to a MySQL database, running an SQL query to retrieve the contents of the "message" table, and displaying that content as form-encoded data.

    Here's an example of what this script might output:

    msg=Happy+Father%27s+Day%21
    Now, when you run the Flash movie, it will access the specified URL, retrieve the form-encoded variable-value pair, parse it, and insert the variable values into the movie. Which is why the Flash movie will look like this:



    Any change to the database record will be immediately reflected in the Flash file - with zero changes required to the Flash source.

    In case you don't want to use a database as your data source, you can even run a shell command and send the output of the command to the Flash movie for display. Consider this variant of the script above, which displays the output of the "fortune" program (a new message every time) whenever the Flash movie is played back in your browser.

    <? $output = `/usr/games/fortune`; echo "msg=" . urlencode($output); ?>


     
     
    >>> More Flash Articles          >>> More By The Disenchanted Developer, (c) Melonfire
     

       

    FLASH ARTICLES

    - An Overview of Flash and ActionScript
    - Building Web Forms In Flash
    - Building Data-Driven Flash Movies
    - Flash 101 (part 6): The Final Countdown
    - Flash 101 (part 5): Spiralling Out Of Control
    - Flash 101 (Part 4): Don't Touch Me!
    - Flash 101 (part 3): Bouncing Around





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT