Chapter 32: Using Flash for CD-ROM Development

One of Flash's powerful features is its ability to gather user data from within the client (the Flash movie within the browser) or display dynamic content that it has retrieved from the server. For instance, you can collect information from your audience through a form or display a constantly changing list of news headlines on your site. In these situations, Flash movies switch from being static to being dynamic, thereby becoming much more versatile and powerful.

When it comes to creating dynamic data-driven applications, there is a marked difference between Flash MX 2004 and Flash MX Professional 2004. In Flash MX 2004, the program really provides only the dynamic frontend (what the user sees in the web browser) for these web applications (as they are called sometimes). The backend (the system used to parse, collect, and serve the information collected from the frontend) is made possible by a host of data-driven technologies. However, in Flash MX Pro 2004, a far more complex and sophisticated system called data binding allows data to be brought into the Flash movie from a series of different sources, and then bound to a component for display or processing. As mentioned in this book's introduction, we elected not to cover data binding in this chapter (where you might have expected it to be covered) because given the extremely complex nature of the subject, it could easily spiral far beyond the scope of the chapter. As a result, this chapter will be light on both the backend technologies and data binding, but heavy on the creation of the dynamic frontend. It will also cover simple ActionScript-based techniques that can be used by all Flash users (not just those with the Professional edition) to display external data in their Flash movie.

Understanding Databases and Data-Driven Sites

Up until a number of years ago, the Web was pretty static. People uploaded pages that contained a fixed, immutable amount of content that changed only when new HTML files were uploaded. Then, much to the collective applause of the development community, dynamic database-driven applications were developed. Rather than forcing people to be passive visitors , dynamic data-driven sites allowed users to change aspects of a page (whether content or design) in real time.

So what exactly is a dynamic data-driven web application? Well, a web application consists of two parts : a frontend and a backend. The frontend consists of the portion of the application in the browser window with which the user interacts . Radio buttons, check boxes, text fields, drop-down menus , submit buttons , and the interface in which they all reside are all part of the frontend. The backend, on the other hand, is generally made up of three elements: a web server, a database (or data source), and a script that makes them all work together. The web server carries out a couple of functions: First, it delivers HTML documents to the user's computer when they are requested . Second, it processes the code that makes the web application work.

The data source, which can be a Microsoft Access database, a web service (something I'll cover briefly later in the chapter), XML, or Structured Query Language (SQL), contains all the information dynamically delivered to the user based on their requests .

 

Note  

SQL is not really a database; it's a language used to format structured queries to databases.

For example, if you were creating a site where a user needed to register before getting access, you would use a database to store, manage, and manipulate username and password information.

 

Note  

Databases are extremely complex subjects in their own right. If you are interested in learning more, there are many good books on databases available. If you're using Microsoft Access (which is usually the database of choice for creating small- to medium- sized web applications), Mastering Access 2002 Premium Edition (Sybex, 2001) by Celeste Robinson and Alan Simpson, is a great place to start.

The script is the heart and soul of the dynamic data-driven application. There are many different solutions you can use to create the script that runs the application. In the section "Introducing the Dynamic Backend" later in this chapter, you'll get an introduction to many of the solutions you can use.

 

Creating the Dynamic Flash Frontend

Where does Flash fit in all this dynamic database-driven stuff? Well, used effectively, Flash is, at the very least, a great tool for building the frontend of a web application. By employing ActionScript, Flash can easily hook up with a host of tools and technologies that provide the backend functionality in any given dynamic web application. In the following sections, you'll go through three steps used to create the frontend of a dynamic Flash web application. The first involves creating the visual interface elements that are used to either input or display data. The second and the third steps, which are somewhat inextricably entwined, involve sending data to the server and, if desired, dynamically displaying data within Flash.

 

Note  

Beyond manually creating the dynamic frontend with text boxes, you can also make use of a series of UI Components designed specifically for data collection and display. For more information on using UI Components , refer to Chapter 16.

Using Text Boxes to Gather and Display Dynamic Information

As covered in Chapter 5, there are three kinds of text in Flash: Static, Input, and Dynamic. You can access the options of each type through the Property Inspector (Window Properties). The first type, Static Text, is the plain-Jane default in Flash. However, the other two types, Input Text and Dynamic Text, are integral parts of any dynamic frontend. In this section, you'll look at each type and explore how you can integrate them into your dynamic database-driven Flash application.

Gathering Data with Input Text Fields

The easiest way to think about an Input Text field is as a container into which the user enters information (their name, a favorite color, and so on). Any text entered into the field is assigned a variable (which you determine). Flash then sends the variable's value (the data entered by the user) to a server or uses it internally. For example, if you assign the variable userName to an Input Text field, anything the user types into that field (whether it's their name or not) becomes the value of userName .

 

Note  

Both the TextArea Components and the TextInput Component can be used in place of the Input Text field to gather data from the user. For more information on each, refer to Chapter 16.

Just like any other type of text within Flash, Input Text is created with the Text tool. Follow these steps:

1.     Create a new document.

2.     Select the Text tool from the Toolbox.

3.     Open the Property Inspector by choosing Window Properties.

4.     Choose Input Text from the Text Type drop-down menu. (For how to work with the Input Text options in the Property Inspector, see Chapter 5.)

5.     Click and drag to define a text box on the Stage.

6.     From here, you have a series of options; the most pertinent to this discussion is the Var field. If you want the Input Text field to work properly, you must enter a variable into the Var field. If you want your field to be visible to the user, make sure you've selected Show Border Around Text.

 

Note  

While Flash doesn't require a variable value (it can rely solely on the TextField instance name), this tutorial does require a value in the Variable field.

7.     To test the Input Text field, save the document and then view it by choosing Control Test Movie (or Control Test Scene). Then type something into the field and select Debug List Variables . In the Output window, you'll get a display like this:

click to expand

Taking the data that the user has entered and sending it to Flash is part of a process (using the getUrl() and loadVariables() actions) that is covered shortly in the section "Moving Data to and from a Server."

Displaying Dynamic Data with Dynamic Text

Dynamic Text is almost the same as Input Text. The only difference is that data is traveling in the other direction-from a data source (such as the server) to the user's browser.

When you create a Dynamic Text field, you create a text box that has content dynamically generated from another source-say, a database or a text file on your server. With this in mind, you can easily come up with some interesting uses. For example, you could create a constantly changing list of your favorite jokes or your daily itinerary . The possibilities are definitely endless.

Let's take a look at how to create Dynamic Text:

1.     Create a new document.

2.     Select the Text tool from the Toolbox.

3.     Open the Property Inspector by choosing Window Properties.

4.     Click and drag to define a text box on the Stage; make sure the size of the text box is appropriate for the amount of text that you want to display.

5.     Choose Dynamic Text from the Text Type drop-down menu in the Property Inspector.

6.     Enter a unique variable name for the Dynamic Text in the Var field. As with the Input Text, if you don't assign a variable, your Dynamic Text won't work.

 

Note  

While Flash doesn't require a variable value (it can rely solely on the TextField instance name), this tutorial does require a value in the Variable field.

Later in this chapter, you'll explore how to put Dynamic Text to work by creating a movie with content drawn from associated text files.

Moving Data to and from a Server

Now that you've explored the visual interface elements used to push data out of Flash and display data within Flash (Input Text and Dynamic Text), it's time to look at the ActionScript necessary to tell Flash where and how you want the data sent. In the next sections, you'll explore getURL() , loadVariables() , loadVariablesNum() , loadMovie() , and loadMovieNum() .

Using getURL()

When it comes to creating dynamic Flash applications, the getURL() action lets you send variables to a given file and display the results in a new window, targeted frame, or existing window. The primary weakness of the getURL() action is that it won't return information to the actual Flash movie in the browser window. As a result, if you instruct Flash to return information to the currently open window, the Flash movie currently playing is replaced . The alternative is to instruct Flash to return the information to a new window by using the blank target (something you'll learn how to do shortly). Granted, this is not a good solution if you want to limit your user's experience to within the Flash movie, but it is your only choice when it comes to the getURL() action.

In the following step-by-step example on how to use the getURL() action, you are going to send a variable to a fictional ASP file (called name.asp ) sitting in the same directory as your movie:

1.     Open a new document.

2.     Select the Text tool from the Toolbox.

3.     Open the Property Inspector by choosing Window Properties.

4.     Click and drag to define a text box on the Stage.

5.     Choose Input Text from the Text Type drop-down menu in the Property Inspector.

6.     Click the Show Border Around Text button to make sure the text box remains visible.

7.     Type userName in the Var field.

8.     Create a simple button (using the Symbol Editor) and place it on the Stage next to the Input Text. (For how to create a button symbol, see Chapter 15.)

9.     Select the Button symbol and choose Window Development Panels Actions.

10.     In the ActionScript toolbox (the left side of the Actions panel where all ActionScript elements are located), expand the Global Functions category, and then expand the Browser/Network category.

11.     Double-click the getURL() action to add it to the ActionScript text box.

12.     From here, you need to enter the necessary parameters. Within the parentheses, enter name.asp . If you were sending information to a web page, simply type in the full URL. If the file you are sending the information to is in a directory other than the one your Flash movie is in, you'll need to type in the exact path . Remember, if you have code hints turned on (which can be done by clicking the Show Code Hints button ), Flash will display the exact syntax of the getURL() Global Function in a pop-up window.

13.     Now enter the window to which you want the information returned. Your options include:

§                               _blank returns the information to a newly opened window (on top of the one the Flash movie is in).

§                               _self returns the information to the current frame in the current window.

§                               _parent returns the information into the parent frame of the current frame.

§                               _top returns the information to the top frame of the current page.

14.     Enter the method by which the information is sent. Your options include:

§                               The GET method sends the information in the form of a query string.

§                               The POST method sends the information via a buffer-far more preferable if you are sending a great deal of information, as it isn't visible in the URL field of the browser.

15.     The action the getURL() Global Function, complete with all the necessary parameters and an example event handler, should look like this:

16.     on (press) {

getURL("http://www.macromedia.com", "_self", "GET");

 

Note  

Remember, you also need to include an event handler in the script for it to work.    For more information on event handlers, refer to Chapter 14.

17.     Your script is complete. Close the Actions window.

Theoretically, when the button is clicked, the Flash movie will take the text that the user entered into the Input Text field and send it to the name.asp file. From there, the ASP file will take the information (which is packaged as the variable/value combination) and do something with it; the something is determined by the ASP file itself, which you need to create.

 

Note  

The window ( _blank , self , and so on) you chose applies only if the ASP file is created so that it sends some kind of data back to be displayed in the browser.

For example, you could construct the ASP file so that it takes the value of the variable userName , and sticks it in a database. Alternatively, instead of sticking it into a database, it could simply send the information to you in an e-mail.

 

Note  

It's worth noting that the variables sent in this fashion must exist in the same clip as the button.

Using loadVariables() or loadVariablesNum()

The getURL() action works well if you want to leave your Flash movie to return the desired information. But what if you wanted the desired information returned and displayed within the Flash movie? This is where the loadVariables() and loadVariablesNum() actions come in.

The two actions return information to either a targeted Movie Clip- loadVariables() -or a level within the main Timeline- loadVariablesNum() -within your Flash movie or update variables with new values inside the active movie.

After you've explored the backend of a dynamic web application (either Flash or regular HTML), you'll get a chance to create a movie that uses loadVariablesNum() to load dynamic content from a series of text files.

Using loadMovie() or loadMovieNum() to Dynamically Load JPEGs

As you've probably figured out, you use getUrl() and loadVariables() / loadVariablesNum() to either display or acquire textual information (at least in this context). So what if you wanted to display something other than text? Well, that's where loadMovie() and loadMovieNum() enter the picture. Both are Global Functions of the Movie Clip object. With them, you can dynamically load JPEG images that reside on your web server-or another web server entirely-into a target Movie Clip ( loadMovie() ) or a level within the main Timeline ( loadMovieNum() ).

 

Note  

What exactly is the difference between loadMovie() and loadMovieNum() ? Well, loadMovie() loads a JPEG (or SWF) into a specific movie clip, while loadMovieNum() loads the JPEG (or SWF) into a specific level.

 

 

Note  

This section focuses on using loadMovie() and loadMovieNum() to dynamically display JPEGs within a Flash movie, but you can also use them to load other SWF files into a movie.

To dynamically load a JPEG using either loadMovie() or loadMovieNum() , follow these steps:

1.     Select the frame, button, or Movie Clip that you want to activate the loadMovie() or loadMovieNum() action.

2.     Open the Actions panel by choosing Window Development Panels Actions.

3.     In the ActionScript toolbox (the left side of the Actions panel with all ActionScript elements), expand the Global Functions category, and then expand the Browser/Network category.

4.     Double-click the loadMovie() or the loadMovieNum() Global Function to add it to the ActionScript text box.

5.     Now, in the portion of the script that requires the URL parameter (indicated by the Code Hint), enter the location and name of the JPEG you want to load. Remember, if the image is in the same directory as the Flash movie, you need enter only the image name. If not, you'll have to enter the exact path (either as an absolute or relative URL) so that the Flash movie can locate it.

6.     If you selected loadMovieNum() , enter the level into which you want to load the image.

 

Note  

For more information on levels, check out Chapter 20.

7.     On the other hand, if you want to load the image into a Movie Clip, enter the instance name of the Movie Clip instance you're loading the JPEG into.

 

Note  

If the Movie Clip you're loading the JPEG into is not a direct child of the current Timeline, you'll need to enter the proper target path using dot syntax. For more information on targeting movie clips in a multiple-timeline movie, refer to Chapter 20.

8.     If you used loadMovie() , your script should look like this:

loadMovie("someimage.jpeg", "somemovieclipinstance");

9.     If you used loadMovieNum() , your script should look like this:

loadMovieNum("someimage.jpg", 2);

 

Note  

Remember, you also might need to include an event handler in the script for it to work. For more information on event handlers, refer to Chapter 14.

10.     When you've finished, close the Actions panel.

When you load directly into the main Timeline, the movie automatically resizes to fit the JPEG exactly. As a result, it's probably better to load into a Movie Clip that is the same size as or larger than its JPEG images. The result is that the Movie Clip will automatically resize to fit the image, and the overall movie won't be affected.

Although using loadMovie() or loadMovieNum() to dynamically load a JPEG is pretty easy, there are two things you need to realize. First, when it comes to using loadMovie() , all the contents of the target Movie Clip will be replaced by the loaded JPEG. Second, only one JPEG can occupy a given level in the Flash movie. As a result, if you load a second JPEG into level1 , the first one you loaded will be automatically replaced.

 

Introducing the Dynamic Backend

Earlier in this chapter, you learned about how dynamic data-driven applications work. Just to refresh your memory, dynamic data-driven web applications have two parts: a frontend and a backend. You explored how to create the frontend of a dynamic web application in Flash. The backend, on the other hand, includes three elements: a server, a database, and a script.

You've already learned how to send data to a web server. In the cases of both the getUrl() and loadVariables() actions, you target the script by entering its correct location. Whether you are using an ASP file (such as the fictional one you used when looking at the getUrl() action) or a CGI script, once you've told Flash where to send the data, the script takes care of the rest.

In the following sections, you'll be introduced to the various types of scripts and technologies available. These sections will help you choose the best solution for your needs and point you in the direction of learning more about that technology.

Web Services

As mentioned at the beginning of the chapter, Flash MX Professional 2004 gives you the ability to bind data from a lot of different sources to a component (for display or processing). In addition, Flash MX Pro 2004 features a number of prebuilt components that allow you to connect to web services and XML data sources.

So, what exactly are web services? First, you need to know that all the data-driven technologies (often called middleware ) discussed next (ASP, PHP, Cold Fusion, and so on) return data in a format that is not particularly generic. As a result, when you are using the vast majority of data-driven technologies, the data that is returned for one application often can't be used in another instance. So, if you want to create another application, you need to re-create the middleware script from scratch. This can be very frustrating because it means that for every application you create, you need to write a unique middleware script that cannot be used in other settings. This is where web services come in. Basically, web services return self-describing , well-structured XML data that anyone can tie into on multiple platforms for multiple applications.

Web services can do the same things as middleware pages (and a lot more), but unlike middleware pages, web services are not tied to any particular software, application, or technology. This is what makes web services so readily available for anyone to use and so easy to port from application to application. And unlike other data-driven technologies, because web services sends back self-describing XML, the tags holding the data relate to the data being returned.

While web services can be written in a number of different languages, they always have a self-created XML document called the WSDL (Web Services Description Language). The WSDL is used to describe how the service itself works, showing each web method, and the arguments that need to be passed to it.

start sidebar

Web Services Info

For more information on web services, check out the following URLs:

§ www.xmethods.com

§ www.webservicex.net

§ www.w3.org/2002/ws

§ www. webservices .org

end sidebar

 

 

Active Server Pages

Active Server Pages (ASP) is a server-side scripting technology developed by Microsoft. ASP is based on an HTML-like syntax in which custom-made VBScript or Jscript (Microsoft's version of JavaScript) resides in specialized tags. Although the most common way to deploy ASP is with Microsoft's Internet Information Server, a number of other methods , mainly Sun's Chili!soft, can deploy ASP on other platforms such as Linux or Solaris.

One of the great joys of ASP (and many other scripting languages) is that it can store site information in a database. As users visit the site, the information is called from the database on a case-by-case basis. As a result, you can make all manner of changes to your layout (font, color, and so on) by changing the ASP code and not the actual HTML page. In addition, like many server-side technologies, ASP can draw upon information within a database to continuously repopulate a web page or a Flash movie with dynamic data.

Although ASP can be written in any text program (such as Notepad or SimpleText), it tends to get pretty complex. As a result, a number of authoring environments are available that can help you develop ASP. Most notably among these is Macromedia's Dreamweaver MX 2004. Built on the same authoring environment as Dreamweaver, Dreamweaver MX 2004 lets you create complex ASP with minimum knowledge of the underlying code.

 

Note  

 On the CD      A demo copy of Macromedia's Dreamweaver MX 2004 is included on this book's accompanying CD.

One of the other great things about ASP is that it can work with any Open Database Connection (ODBC)-compliant database. As a result, you can create your database in a wide range of programs.

ColdFusion

Originally developed by Allaire (which was acquired by Macromedia in 2001), ColdFusion is a dynamic database-driven application technology that uses a unique tag-based server scripting language-ColdFusion Markup Language (CFML)-in conjunction with a specialized server-ColdFusion Server-to deliver powerful dynamic web applications. Because ColdFusion's CFML scripting language is similar to HTML, it is fairly easy to learn and use.

When a user requests a ColdFusion document (which is called a template and has a .cfm extension), the web server passes the file first to the ColdFusion Server (which sits on the web server itself) before passing it to the user's browser. The ColdFusion Server looks at the template, interpreting the embedded CFML. The ColdFusion Server then generates the output from the CFML in the template and returns the file to the web server to be passed back and displayed in the user's browser.

Let's take a look at a short example. Say, for instance, that you've created a ColdFusion template with all the necessary CFML to create a list of books you have read. When a user tries to load that file (remember, it's called a template ) into their browser, the server notices the .cfm extension and passes the request onto the ColdFusion Server. Now when the ColdFusion Server receives the request, it pulls the list of books from a database (which you keep constantly updated), puts the data in the appropriate places in the template (which are designated using CFML), and passes the file back to the web server. The web server then sends the file to the user's browser, letting them view the list.

Unlike ASP (which requires only a specific type of web server), ColdFusion actually needs the ColdFusion Server software that sits on the web server to work properly.

 

Note  

To learn more about ColdFusion, go to www.macromedia.com/coldfusion .

Just as with ASP, you can set a ColdFusion template as the target URL for either a getUrl() or a loadVariables() Global Function. Once information (in the form of actual data or a request for data) is sent to a CFM document, ColdFusion returns the data back to Flash to be displayed in the manner you've defined (either in the Flash movie itself or in another window).

You can generate CFML a number of ways. You can simply write it from scratch as you would with HTML. You can also use either Macromedia Dreamweaver MX 2004 or ColdFusion MX (available from Macromedia).

PHP

Back in 1994, Rasmus Lerdorf developed a series of Perl (Practical Extraction and Reporting Language) scripts that allowed him to monitor the users who accessed his website. Word got around about Lerdorf's interesting invention, and people started asking to use his scripts on their pages. Shortly thereafter, Lerdorf released them as a package called Personal Home Page (PHP) Tools.

By 1995, PHP-whose full name was changed from Personal Home Page Tools to PHP Hypertext Preprocessor-had gained a large following. The popularity of PHP prompted Rasmus to release a scripting engine and additional scripts designed to process data from forms.

When the third incarnation of PHP (PHP3) was released, it included a far more efficient scripting engine. The syntax of PHP was changed so that it looked more like a cross between C/C++ and Perl instead of just straight Perl (which isn't an object-oriented programming language). To allow third-party developers to further extend PHP by developing their own modules, PHP3 included an Application Programming Interface (API).

The current release of PHP (PHP4) has been completely reworked to give users far more control over their PHP creations. The API now more efficiently integrates third-party PHP modules.

PHP's benefits lie in several different areas. First, you can write PHP with a simple text utility such as Notepad, SimpleText, or Emacs. Like many server-side scripting technologies (including all those discussed in this chapter), PHP can draw information from any ODBC-compliant database on the server. PHP can be installed on most web servers (Windows- or Unix-based). Generally speaking, PHP is reported to be faster and more stable than both ASP and ColdFusion. All these benefits are great, but the best is that it's free. You can use it for noncommercial or commercial applications, trade it with friends , hang it on your wall, burn it to a CD, or use it to play fetch with your dog. Further, because PHP is open source, tens of thousands of developers are working hard to develop modules that do new things.

As with any of the other technologies discussed so far, you can set a PHP file (which has a .php extension) as the target URL for either a getUrl() or loadVariables() action. Once information (in the form of actual data or a request for data) is sent to a PHP document, the PHP server returns the data to Flash to be displayed in the manner you've defined (either in the Flash movie itself or in another window).

 

Note  

To find out more about PHP, go to www.php.net . You can also visit www.phpbuilder.com . If you're interested in open-source software, try www.opensource.org .

Common Gateway Interface

Common Gateway Interface (CGI) was around long before anyone ever thought of dynamic database-driven applications. To be honest, CGI isn't a programming language in itself. It's really a technology that allows the development of server-side programs that extend the functionality of HTML (and Flash, for that matter).

Although Perl is by far the most popular programming language to develop CGI, there are certainly other options, including C/C++, Visual Basic, Applescript, Unix Shell, and Tcl.

As with all of the other technologies discussed, you can target a CGI file with the getUrl() or loadVariables() actions. Data passed out of Flash is processed by the particular CGI script and then returned and displayed in the method you determine.

 

Note  

For more information about CGI, visit www.scriptsearch.com or www.cgi-resources.com .

 

Generating Dynamic Content from Text Files

Now that you've looked at both the frontend and backend of dynamic database-driven web applications, it's time to create a Flash movie that displays dynamic information. In this section, you're going to take everything you've learned and create a Flash movie that displays information from text files. Granted, this is not particularly dynamic per se because the text files contain information that is static. The point of the exercise is that you'll be creating a Flash movie that draws and displays information from another source by using ActionScript (more specifically, the loadVariablesNum() action discussed earlier). To create something truly dynamic, you would have to use one of the previously mentioned technologies.

During this step-by-step example, you'll create four different buttons that, when clicked, load the contents of four text files (each a quotation from a literary figure or an orator) into the Flash movie.

 On the CD      Although you certainly can use any text file you want, the Bonus Chapter 1 directory on this book's accompanying CD contains the four text files referred to in the following example. In addition, the quotes.swf file is an example of what the end result should be. As usual, however, the process is more important than the end result. So, let's get to it:

1.     Create a folder on your hard drive called Flash Quote Project . Then copy all the text files in the Bonus Chapter 1 directory to the folder.

2.     Create a new file by choosing File New.

3.     When the New Document dialog box opens, select Flash Document, and click OK.

4.     Before you create anything, save the file to the Flash Quote Project directory and call it quotes .

 

Note  

If you've copied the quotes.fla from the Bonus Chapter 1 directory, the newly saved file will overwrite it. If you want to avoid this, either refrain from copying the finished quotes.fla from the CD-ROM or simply give your file another name.

5.     Name the existing layer Dynamic Text .

6.     Select the Text tool from the Toolbox.

7.     Open the Property Inspector by choosing Window Properties.

8.     In the Property Inspector, select the Dynamic Text option from the Text Type drop-down menu.

9.     Make sure Multiline is selected in the Line Type drop-down menu.

10.     Select the first keyframe of the Dynamic Text layer and use the Text tool to draw an area roughly 10 centimeters (4 inches) wide and 7 centimeters (2.75 inches) high. This will serve as the "container" in which Flash will display the contents of each of the text files.

11.     Now, for the most important part, enter quoteField into the Property Inspector's Variable field. If you take a look at each of the text files, you'll notice the words quoteField= at the beginning of each text file. This string links each text file to the Dynamic box you've just created.

12.     You want to set the look of the text when it's displayed in the Dynamic Text field. So, with the field you created still selected and the Property Inspector still open, set your font to Helvetica/Arial, the color to Black, the size to 12, and the style to Bold and Italic.

13.     Now that you've created the Dynamic box in which Flash will place the text drawn from the text files, it's time to create the interactive controls that will call the content from each individual text file. You can create four buttons with the words Homer , Plato , Frost , and Melville on each, respectively. Alternatively, you can just choose File Import Import to Library, navigate to and select the quotes.swf file on the book's accompanying CD, and use the buttons that are included.

14.     Create four additional layers and assign them the same names as the buttons (Homer, Plato, Frost, and Melville). Click and drag each button individually to their respective layer. Make sure the buttons are placed in an evenly spaced line below the Dynamic Text field. So far, your Stage should look something like this:

click to expand

15.     Now you need to attach the ActionScript to each of the buttons so that when clicked, the appropriate text is loaded into the Dynamic Text field. Select the first button in the row (Melville) and choose Window Development Panels Actions to open the Actions panel.

16.     Enter the following script into the ActionScript text box:

17.     on (release) {

18.           loadVariablesNum("melville.txt", 0);

}

19.     Repeat the process described in steps 15 and 16 to link each button to the appropriate text file. Make sure that when you create the script for each button, you reference the right text file.

20.     Test your movie by choosing Control Test Movie or Control Test Scene.

 

Inspirational Design Model

In recent years, the world of dynamic Flash has grown in popularity. A recent, and very interesting, example is the Electronic Arts' The Lord of the Rings: Return of the King website (see Figure B1.1). Designed as a promotion for the Lord of the Rings: Return of the King video game, the site ( http://rotk.ea.com ) features a mix of Flash and HTML. With the help of JSP, the site allows you to customize the user interface by clicking one of the game character's animated Flash portraits-very cool indeed.

click to expand
Figure B1.1: The Electronic Arts' Lord of the Rings Return of the King video game site

 



Flash MX 2004 Savvy. Also Covers Flash Professional.
Flash Mx2004; Also Covers Flash Professional; Savvy
ISBN: 0471789151
EAN: 2147483647
Year: 2003
Pages: 54

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