Flash Samples
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are eith
Contents Chapter 1: Graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Animated drop shadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Animation and gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Chapter 2: Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Accessibility features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Drawing with ActionScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 ActionScript arrays example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Interaction between the browser and Flash Player . . . . . . . . . . . . . . . . 28 Stage size control with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Text loading with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introduction Macromedia Flash Basic 8 and Macromedia Flash Professional 8 provide everything you need to create and deliver rich web content and powerful applications. Whether you’re designing motion graphics or building datadriven applications, Flash has the tools necessary to produce great results and deliver the best user experience across multiple platforms and devices. The samples in this book are designed to introduce you to Flash.
Introduction
CHAPTER 1 Graphics 1 Graphics samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Animated drop shadow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Animation and gradients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
To prevent this effect from looking too much like a drop shadow against a flat wall behind the original object, you can use the Free Transform tool to skew the filtered movie clip instance. This technique takes a bit of trial and error. Squash and skew the instance until it looks as if the shadow is being cast upon a floor. (You may need to reposition the instance.) Test the movie clip, and you see the effect come to life. You can find the sample source files, drop_shadow_dog.fla and drop_shadow_monkey.
The next step is to create a movie clip symbol and place this eight-ball graphic inside it. Inside this movie clip is where the “8” graphic is added along with a mask layer. Then add a mask that is the same size and shape as the eight ball, and use the Free Transform tool and motion tweening to create the illusion of the ball rolling in various directions by moving and squashing the “8” graphic across the surface of the circle.
Graphics
CHAPTER 2 Accessibility 2 An accessibility sample is provided when you install Macromedia Flash 8. This chapter contains a brief overview of this sample. This chapter contains the following section: Accessibility features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Accessibility features This sample shows how to use accessibility features such as tab ordering, components, and the Accessibility panel.
Accessibility
CHAPTER 3 Masking 3 Masking samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Device font masking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Scriptable masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Device font masking This sample explores Flash Player support for masking device fonts.
Scriptable masks This sample shows how to dynamically mask Flash content at runtime using scriptable masks and components. Scriptable masking allows precise control over how masks behave at runtime, and allows the mask and the masked content to be dynamically changed at runtime. This sample shows different types of masks and masked content that are controlled by a user interface built with components. Explore this sample to learn more about masking and building interfaces with components.
CHAPTER 4 Text 4 Text samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Text sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Multilingual content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Multilingual content This sample, featuring the Strings panel, shows a streamlined approach to developing and managing content in several languages. The new Strings panel provides for easy and fast content development in different languages. Localized content for text fields inside the document is kept in language-specific XML files in directories alongside the document. This sample has content in several languages. The language displayed corresponds to the current language of the host operating system.
CHAPTER 5 Behaviors 5 A behaviors sample is provided when you install Macromedia Flash 8. This chapter contains a brief overview of this sample. This chapter contains the following section: Photo scrapbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Photo scrapbook This sample shows how to build an interactive photo scrapbook by using behaviors instead of scripting.
Behaviors
CHAPTER 6 Components 6 Several component samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Component application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Dial component sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Login component sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Tip calculator. . .
Dial component sample This sample provides an example of a dial component with a getter/setter property that gets or sets the position of the needle on the dial. This sample is discussed in “Building your first component” in Using Components. You can find the sample source file, Dial.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\Components\DialComponent.
The LogIn sample component uses Button, Label, and InputField component movie clip symbols to create a simple name and password login interface that dispatches a click event when the Login button is clicked. The sample includes a document file (.fla) containing the LogIn component movie clip symbol in its library and the LogIn component’s class ActionScript file (.as), which defines its class properties and methods.
Components jukebox This sample demonstrates how to create a jukebox by using data types, general coding principles, and several components. You can find the sample source file, jukebox.fla, in the Samples folder on your hard disk. 22 Components ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\Components\Jukebox. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/Components/ Jukebox.
CHAPTER 7 ActionScript 7 Several ActionScript samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Custom Flash Player context menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Filters with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Animation with ActionScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Custom Flash Player context menu In this sample, you can see how to add custom options to the Flash Player context menu using ActionScript 2.0. This sample uses ActionScript to modify the context menu by adding cut, copy, and paste functionality that can be applied to the drawing objects on the Stage. The source includes the document file (.fla) and the ActionScript file (.as) that defines the ClipBoard class. Explore both files to learn more about the context menu and writing classes with ActionScript 2.0.
Animation with ActionScript This sample provides an example of programmatic animation using ActionScript. It shows a simple game where instances are animated across the Stage at runtime. You create a custom mouse pointer, and you can tally scores by manipulating strings and using operators to write equations. You can find the sample source file, animation.fla, in the Samples folder on your hard disk.
ActionScript data types This sample provides an example of converting data from one type to another. You can find the sample source file, datatypes.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\DataTypes. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/ DataTypes.
Drawing with ActionScript This sample demonstrates how to draw lines and create, fill, sort, and remove shapes with ActionScript. You can find the sample source file, drawingapi.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\DrawingAPI. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/ DrawingAPI.
Interaction between the browser and Flash Player This sample demonstrates how to use the External API (ExternalInterface class) to create interaction between the browser and your SWF file. In this sample, HTML form controls on a web page let you manipulate and display information about an FLV video that plays in a SWF file. Messages from the SWF file appear in an HTML text field. You can find the sample source file, external.fla, in the Samples folder on your hard disk.
Text loading with ActionScript This simple sample shows how to load text into a SWF file at runtime using the LoadVars class. You can find the sample source file, loadText.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\LoadText. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/ LoadText.
Login sample This sample shows how to add simple login functionality to your websites using ActionScript 2.0. The sample uses ActionScript and components to create a small form in which you enter a user name and password and then click a button to enter a site. You can find the sample source file, login.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\Login.
Image manipulation with the BitmapData class This sample demonstrates how to manipulate an image and create a transition using the BitmapData class. You can find the sample source file, BitmapData.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\BitmapData. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/ BitmapData.
Photo gallery with tree navigation This sample is a photo gallery application with tree navigation. It provides an example of using components to control movie clips dynamically. You can find the sample source file, gallery_tree.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\Galleries.
File upload with the FileReference API This sample demonstrates how to let users select a file on their hard disk and upload it to a server. After the local image uploads, it appears in the SWF file. You can find the sample source file, FileUpload.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\FileUpload.
XML language picker This sample demonstrates how to use XML and nested arrays to choose strings of different languages to populate text fields. You can find the sample source file, xml_languagePicker.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\XML_LanguagePicker.
CHAPTER 8 Data Integration 8 Several data integration samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. If you installed Flash Basic 8, you can view and explore these samples. However, you can reconstruct the samples only if you installed Flash Professional 8. This chapter contains the following sections: News reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 WebServiceConnector component .
You can find the sample source file, DevNetNews.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\DataIntegration\NewsReader. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/DataIntegration/ NewsReader. WebServiceConnector component This sample demonstrates how to use the WebServiceConnector component. You can find the sample source file, tips.
Flash and PHP integration This sample demonstrates how to use Flash and PHP (Hypertext Preprocessor) integration to create a guestbook. You can find the sample source file, guestbook.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\DataIntegration\Guestbook. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/DataIntegration/ Guestbook.
Data Integration
CHAPTER 9 Extending Flash 9 As a Macromedia Flash user, you may be familiar with ActionScript, which lets you create scripts that execute at runtime in Macromedia Flash Player. The Flash JavaScript application programming interface (JavaScript API) is a complementary programming tool that lets you create scripts that run in the authoring environment (that is, while a user has the Flash program open). These scripts can be used to help streamline the authoring process.
Shape command This sample displays information about the contours of the selected shape in the Output panel. You can find the source file for this script, Shape.jsfl, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ExtendingFlash\Shape. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ExtendingFlash/ Shape.
PolyStar tool This sample provides an example of adding a tool to the Tools panel using the JavaScript API. You can find the source file for this script, PolyStar.jsfl, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ExtendingFlash\PolyStar. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/ExtendingFlash/ PolyStar.
Sample DLL Advanced users can use the C-level extensibility mechanism to implement Flash extensibility files using a combination of JavaScript and custom C code. You define functions using C, bundle them in a dynamic linked library (DLL) or a shared library, save the library in the appropriate directory, and then call the functions from JavaScript using the JavaScript API.
CHAPTER 10 Flash Lite 10 Several Macromedia Flash Lite samples are provided when you install Macromedia Flash 8. This chapter contains a brief overview of each sample. This chapter contains the following sections: Two-way navigation sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Four-way navigation sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Input text field sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
You can find the sample source file, 2-way.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\FlashLite. ■ On the Macintosh, browse to Macintosh HD/Applications/ Macromedia Flash 8/Samples and Tutorials/Samples/FlashLite. Four-way navigation sample This sample demonstrates four-way navigation in Flash Lite.
Movie clip menu sample This sample demonstrates how to create a simple menu out of movie clips. For more information about how this sample was constructed, see “Creating a simple menu using movie clips” in Developing Flash Lite Applications. You can find the sample source file, movieclip_menu_complete.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\FlashLite.
Animated cartoon This Flash Lite sample shows how to create an animated cartoon in Flash Lite. The design shows the optimized use of vector and bitmap graphics to create smooth animation on a mobile device. Explore the source file to learn more, or customize it by creating your own animated cartoon. You can find the sample source file, FLAnimatedCartoon.fla, in the Samples folder on your hard disk. ■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\FlashLite.
Strategy game This Flash Lite sample shows how to create a Flash Lite strategy game similar to the popular games Tetris and Breakout. The game uses the handset’s joypad to navigate blocks dynamically drawn on the screen. The joypad is the main input device for the game. Explore the source file to learn more, or customize it by creating your own strategy game. You can find the sample source file, FLStrategyGame.fla, in the Samples folder on your hard disk.
Flash Lite