Using an External Data Source


Although using a native data source is convenient for testing, being able to tap into an external data source gives you a lot more flexibility. If you have the Generator 2 server extensions installed on your Web server, using an external data source enables you to change the output for your template every time you update your data source, without having to reopen your Flash file. The external data source can be a comma-delimited text file, an ODBC/JDBC-compliant database, or a Java class.

So far, you've used only two variables for your ad banner. In the next exercise, you put those name /value pairs in an external text file. You then use that text file as your data source for the next few exercises. Later in this chapter, you draw information from multiple data sources. Start now by creating your first external data source.

Exercise 4.4 Adding an External Data Source

Creating a text file as an external data source is a straightforward process. You just type in your name/value pairs exactly as you did for the internal data source. This time, however, you leave out the leading pound (#) sign.

  1. Open the text editor of your choice. Notepad works well in the PC environment. SimpleText is a good choice for Mac users.

  2. Enter the following (see Figure 4.10):

    name, value

    companyName, Fig Leaf Software

    tagLine, We've got you covered!

    Figure 4.10. Setting up an external data source using a text editor.

    graphics/04fig10.gif

  3. Save your file as data.txt. Make sure you save your text file in the same directory as your Flash file.

    Note

    You don't have to save your data source in the same directory as your Generator template. If you do choose to save your data source in a different directory, you need to make sure that you give Generator the proper path to the file when you reference it. If Generator doesn't understand the path you give it, your file is not processed correctly.

  4. Open banner3.fla if it is not already open. Click the Generator Environment Variable button.

  5. Replace all the information (your old name/value pairs) with data.txt. (See Figure 4.11.)

    Figure 4.11. Replace the native data source with the path to the external data source.

    graphics/04fig11.gif

  6. Save your file as banner4.fla and test your movie.

    You should see exactly the same thing that you saw when using the native data source, but now you are drawing the values from the comma-delimited text file data.txt.

    You'll continue to use your new external data source for the next few exercises, so leave your text editor open.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net