Home arrow Flash arrow Page 2 - Building Data-Driven Flash Movies

Message In A Bottle - Flash

Contrary to what you might think, Flash isn't just all tweensand motion blurs. The application comes with powerful data-retrievalcapabilities, which allow you to hook your Flash movie clips up to adatabase (or any other external data source) and dynamically build movieclips that are easy to update and modify. Find out more, in this roughguide to the data-driven Flash universe.

TABLE OF CONTENTS:
  1. Building Data-Driven Flash Movies
  2. Message In A Bottle
  3. No Hands
  4. No News Is Good News
  5. Alien Invasion
  6. What's On The Menu?
  7. Splitting Up
  8. Linkzone
By: The Disenchanted Developer, (c) Melonfire
Rating: starstarstarstarstar / 71
July 23, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Before we get started with building a database-driven animation clip, you need to know a little theory.

The first - and most critical - thing you need to know is that there is never direct communication between Flash and a database. A Flash movie can never talk directly to a database server - there is always a third party involved. This third party takes care of building and transmitting the query from the movie to the database, and retrieving and massaging the results into a format that is usable by the movie clip.

This third party's role is usually played by a server-side application such as Perl, PHP, ASP, ColdFusion et al.

In order to better understand this, let's consider a simple example. Pop open Flash, create a new movie and then create a new Graphic symbol. Name it "message".



Now, in the Symbol Editor, create a text box with the Text tool (hit A on the keyboard). Use the Window -> Panels -> Text Options panel to turn it into a dynamic, multi-line text box.



While you're there, also set a variable name for the newly-minted dynamic text box - this is the variable that Flash will look for when the time comes to populate the text box. I've used the variable name "msg".



Back in the Scene Editor, drag and drop a copy of your newly-created symbol onto the Stage.



In the timeline, select the first frame (this should be a keyframe), right-click it and pop up the Actions dialog box. On the left-hand side of the Actions panel, look in the "Basic Actions" sub-category and select the loadVariables() function. This ActionScript function allows you to load variables into the Flash movie from an external URL - more on how this works later.

The lower half of the Actions panel should prompt you to enter some parameters for this function - specifically, the URL to get the variables from. For the moment, let's assume that the variables will be loaded from the URL "message.txt" - specify this in the lower half of the panel, as shown below.



The file specified as the variable source must contain data in the MIME format "application/x-www-urlformencoded" - that is, a series of variable-value pairs separated by ampersands (&). Here's what my copy of "message.txt" looks like:

msg=Welcome to the wonderful and wacky world of dynamic data sources!
Obviously, this file should be stored in the same place as the Flash movie (you can store it elsewhere too, just remember to alter the URL supplied to loadVariables() appropriately).

Now, when the Flash movie plays, the contents of the file "message.txt" will be read, converted to variables and used within the Flash movie. Take a look:



Wanna change the message? Just alter the contents of "message.txt",

msg=Look, Ma, no hands!
and watch in amazement as your Flash movie changes as well!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: