Developing Flash Lite 2.
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 Endocer, 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: Flash Lite 2.x Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 About Flash Lite 2.0 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Flash Lite 2.0 new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 About components in Flash Lite 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Chapter 2: Creating Interactivity and Navigation . . . . . . . . . . . . . .
Chapter 6: Testing Flash Lite Content (Flash Professional Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Overview of Flash Lite testing features (Flash Professional only) . . . 81 Testing features not supported by the Flash Lite emulator . . . . . . . . . 84 Using the Flash Lite emulator (Flash Professional only). . . . . . . . . . . . 84 Flash Lite error and warning messages (Flash Professional only) . . .
1 CHAPTER 1 Flash Lite 2.x Overview Macromedia Flash Lite 2.0 is a version of Flash Player designed for devices. Flash Lite 2.0 is based on Flash Player 7 and supports most—but not all—features in Flash Player 7. Flash Lite 2.0 also includes features specific to mobile development that are not available in Flash Player 7. For example, in Flash Lite 2.0 you can load device-specific media types (images, sounds, video) that aren’t natively supported by Flash Lite. Flash Lite 2.
■ Ability to control backlight duration and set custom focus rectangle color ■ Support for ActionScript 2.0, which lets you use advanced programming techniques including classes, interfaces, and strict data typing ■ Synchronized device sound ■ XML processing support The following features in Flash Player 7 are not available in Flash Lite 2.0: ■ Several ActionScript classes available in Flash Player 7 are unsupported or partially supported in Flash Lite 2.0.
You can use ActionScript 2.0 or ActionScript 1.0 syntax when you develop applications for Flash Lite 2.0. ActionScript 2.0 provides authoring support for classes, interfaces, and strict data typing. Using ActionScript 2.0 syntax lets the ActionScript compiler provide better debugging information, and also encourages better program design. For more information about learning Flash Lite 2.0 ActionScript, see the following books and topics: ■ Introduction to Flash Lite 2.x ActionScript ■ Flash Lite 2.
To load external sounds, you use the Sound.loadSound() method. In Flash Lite 2.0, you can use this method to load any sound format that the device supports (for example, MIDI or SMAF). External device sounds must fully load into memory before they can play. As in Flash Lite 1.x, in Flash Lite 2.0 you can also play device sound that’s bundled in the SWF file. For more information, see “Using bundled device sound” on page 48.
New text features The following features related to text handling are new in Flash Lite 2.0: ■ All text in Flash Lite 2.0 is Unicode based. ■ Flash Lite 2.0 provides partial support for HTML formatting and the TextFormat ActionScript class. For more information about working with text fields in Flash Lite 2.0, see “Working with Text and Fonts” on page 33. Additional key support Flash Lite 2.
Flash Lite 2.
CHAPTER 2 2 Creating Interactivity and Navigation To interact with your Macromedia Flash Lite application, a user must be able to determine which object on the screen currently has focus, navigate among objects, and initiate an action by selecting an object or another key. While these basic principles are the same as for desktop applications, some of the functionality varies for mobile devices. This chapter contains the following topics: About user interaction in Flash Lite . . . . . . . . . . . . . . . .
Keys supported by Flash Lite In addition to the alphanumeric keys available on standard telephones, most mobile devices feature a navigation keypad, which let users navigate and select items on the device screen, and two (or more) soft keys. A device’s soft keys are multifunctional keys that use the screen to identify their purpose at any moment. A typical navigation keypad has four navigation keys (up, down, left, and right) and a select key (typically located at the center of the keypad).
Description Keyboard keys Keys Availability SOFT3 - SOFT12 keys Devices that have more than two soft keys !, “, #, $, %, &, ‘, (, ), *, +, ,, -, ., Devices that have a QWERTY /, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, keyboard <, +, >, ?, @, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, [, \, ], ^, _, ‘, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, {, |, }, ~, Backspace The following System.
Default navigation modes Flash Lite supports three modes of default navigation: two-way, four-way, and four-way with wraparound. Different devices and Flash Lite content types support different navigation modes. For information on determining the navigation mode for a specific device and content type, see “Flash Lite platform capabilities (Flash Professional only)” on page 101.
Four-way navigation in Flash Lite is similar to using the arrow keys on a desktop computer’s keyboard to navigate among objects on the screen. The device’s up, down, left, and right navigation keys correspond to the four arrow keys on a computer’s keyboard. Pressing a navigation key moves the keypad focus to the object located in that direction, if one exists. If no object exists in that direction, then the keypad focus does not change from the current object.
To use each sample file, open it in Flash and test it in the emulator (select Control > Test Movie). Click the arrow keys on the emulator’s keypad (or press the arrow keys on your keyboard) to see how each navigation mode affects user navigation. f Array of buttons in sample file About the focus rectangle By default, Flash Lite draws a yellow rectangle around the button or input text field that has focus.
Guidelines for using default navigation The following are guidelines and considerations for using default navigation in your Flash Lite applications. ■ If you disable the default focus rectangle by setting _focusRect to false, be sure to provide an alternative focus indicator for your buttons, input text fields, and tab-enabled movie clips. For buttons, you can do this by adding a visual element to the button’s “over” state—the part of a button object’s timeline that’s displayed when the button has focus.
Customizing the focus rectangle The focus rectangle is a default yellow highlight that indicates which button or input text box is currently selected. Movie clips are also included if their tabEnabled property is set to true, or if they have event handlers associated with them and their tabEnabled property is not set to false. For more information, see “About the focus rectangle” on page 16. You can disable the default focus rectangle behavior by setting the global _focusRect property to false.
3. With the text field still selected, in the Property inspector, select Input Text from the Text Type pop-up menu, type inputTxt_1 in the Instance Name text box, and select the Show Border Around Text option. 4. In the same manner, create another input text field below the first one with the instance name of inputTxt_2 and select the Show Border Around Text option for the second text field. 5. In the Timeline, select Frame 1 in the layer named ActionScript. 6.
About controlling tab order in two-way navigation Two-way navigation in Flash Lite is analogous to tab navigation in Flash, and therefore supports the tabIndex property that allows you to specifically set the tab order of buttons, movie clips, and input text fields. On devices that support four-way navigation, the tabIndex property is not supported, so it’s not possible to set tab order using the tabIndex property for four-way navigation.
Handling button events (Flash Professional only) You can use buttons to quickly add interactivity to your Flash Lite applications. Flash Lite supports the same button events as Flash Player on desktop computers, although some events (for example, onDragOut) are only available on devices that have a mouse or stylus interface. On devices that have a keypad interface only, a button must have keypad focus before it will generate any events.
2. Select Window > Common Libraries > Buttons to open an external library of prebuilt button symbols. 3. In the Library panel, double-click the classic buttons folder to open it, and then open the Circle Buttons folder. 4. Drag an instance of the Menu button symbol to the Stage. 5. In the Property inspector, in the Instance Name text box, type btn_1. 6. Drag another instance of the same button to the Stage and position it directly below the first button. 7.
10. Test the application in the emulator (Control > Test Movie). Watch the messages in the Output panel as you press the up and down arrow keys on the emulator’s keypad. Other types of objects support different events; for example, the TextField object includes an onChanged event that is invoked when the content of a text field changes. You can write event handler code for these events using the same format as the button event handlers in this procedure.
To create a simple menu using buttons: 1. Open the file named simple_menu_start.fla, which is located in the Samples and Tutorials/ Samples/Flash Lite 2.0/ folder in the Flash installation folder on your computer. 2. Open the Library panel (Window > Library). Notice that the Library contains three button symbols named News Button, Weather Button, and Sports Button. 3. In the Timeline (Window > Timeline), select the layer named Menu Buttons. 4.
9. With the new text field still selected, do the following in the Property inspector: a. Select Dynamic Text from the Text Type pop-up menu. b. Type txt_status in the Instance Name text box. The Stage should look something like the following image: 10. In 11. the Timeline, select Frame 1 in the layer named ActionScript. Open the Actions panel (Window > Actions) and enter the following code: // Disable the focus rectangle because buttons have an over state _focusRect = false; btn_news.
12. Select Control > Test Movie to preview the application in the emulator. Click the down arrow key on the emulator with your mouse (or press the down arrow key on your computer’s keyboard) to navigate between menu options; to select a menu item, click the emulator’s select key by using your mouse (or press the Enter key on your computer’s keyboard). Handling key events Flash Lite generates key press events in response to the user pressing keys on their device.
The following table lists commonly used device keys and the corresponding ActionScript key codes and key code constants for those keys: Device key ActionScript key code/key code constant Select key Key.ENTER Up navigation key Key.UP Down navigation key Key.DOWN Left navigation key Key.LEFT Right navigation key Key.RIGHT Left soft key ExtendedKey.SOFT1 (or soft1) Right soft key ExtendedKey.
Writing an event listener Event listeners let an object, called a listener object, receive events broadcast by another object, called a broadcaster object. The broadcaster object registers the listener object to receive events generated by the broadcaster. For more information, see “Using event listeners” in Learning ActionScript 2.x in Flash. A easy way to handle key press events is to create a key listener object that defines an onKeyDown or onKeyUp function, and then register that object with the Key.
6. Open the Actions panel (Window > Actions), and enter the following code: var myListener:Object = new Object(); myListener.onKeyDown = function() { if (Key.getCode() == Key.LEFT) { circle._x -= 10; } else if (Key.getCode() == Key.RIGHT) { circle._x += 10; } else if (Key.getCode() == Key.UP) { circle._y -= 10; } else if (Key.getCode() == Key.DOWN) { circle._y += 10; } }; Key.addListener(myListener); 7. Test the application by selecting Control > Test Movie.
The following example shows the result of using this command in an application running on an actual device in normal (not full-screen) mode: Available screen area in non-full-screen applications Soft key labels displayed by device If you enable full-screen mode—that is, if you call fscommand("fullscreen", true)—the labels that you specify as parameters to the SetSoftKeys command are not visible.
3. Create another static text field named Right, and position it in the lower-right corner of the Stage, above the right soft key on the device. 4. Using the Text tool, create a dynamic text field, and position it in the middle of the Stage. Your document’s Stage should look like the following example: Dynamic text field Soft key labels 5. With the dynamic text field still selected, in the Property inspector, type status in the Instance Name text box. 6.
9. Select Control > Test Movie to test the application in the emulator. To test the application, click the left and right soft keys on the emulator with your mouse, or press the Page Up and Page Down keys on your keyboard.
3 CHAPTER 3 Working with Text and Fonts This chapter describes how you can add static and dynamic text fields and add input text fields to your Macromedia Flash Lite applications. This chapter contains the following topics: About text in Flash Lite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Creating and formatting text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Using input text fields . .
■ Partial support for HTML formatting and the TextFormat class properties ■ Scrolling text Flash Lite does not support all the text features that are in the desktop version of Flash Player. Flash Lite has the following limitations: ■ FlashType, the enhanced font rendering technology available in Flash Player 8 and later, is not supported. ■ Text formatting is supported, but the following limitations apply for device text: ■ Only the color, face, size, bold, and italic options are available.
Using input text fields Input text fields in Flash Lite, like dynamic text fields, let you get and set their contents at runtime with ActionScript. In addition, input text fields let Flash Lite applications get user input using the device’s generic input text dialog box. (Flash Lite does not support inline text input.
The Flash Lite emulator mimics the features of the text input dialog box when you test your application in the Flash authoring tool. The following image shows the text input dialog box running in the emulator: ‘ Text input dialog box running in the emulator For an example of using an input text field in an application, see “Text field example application (Flash Professional only)” on page 42. Types of input text fields Flash Lite supports single line, multiline, and password input text fields.
For example, when a user edits a single line input text field, the device’s input text dialog box displays a single line input text box. The input text box scrolls horizontally if the user enters more characters than can be displayed.
Restricting character input You can use the SetInputTextType command to restrict the characters that the user can enter in the text input dialog box. For example, suppose an application contains an input text field for users to provide a numeric value, such as their age. Furthermore, suppose that the input text field has the variable name ageVar.
To select a font rendering method for a text field: 1. Select a text field on the Stage. 2. In the Property inspector, select one of the following options from the Font Rendering Method pop-up menu: ■ Select Use Device Fonts to have Flash Lite use a font that is available on the device. No font data is embedded in the published SWF file. ■ Select Bitmap Text (No Anti-Alias) to have Flash Lite align font outlines along pixel boundaries, which makes small text appear crisp and clear.
■ Anti-aliased text in Flash Lite is, essentially, a complex vector shape. Like any vector shape, it takes some processing power to render. Because processing speed on most devices is relatively slow, animating a lot of anti-aliased text may degrade application performance. To improve performance, try temporarily lowering the Flash Lite player’s rendering quality during the animation, and then returning it to the higher rendering quality when the animation is complete.
Embedding font outlines in SWF files To render a text field’s font, Flash Lite can either use fonts that are available on the device or use font outlines that are embedded in the published SWF file (see “Font rendering methods in Flash Lite” on page 38). Embedding font outlines in the SWF file ensures that the text field’s font appears the same on all target platforms, but results in larger file size. Flash Lite requires font outlines to render either bitmap (no anti-alias) or anti-aliased text.
3. Click the Embed button located next to the Font Rendering Method menu to open the Character Embedding dialog box. 4. Select the characters you want to embed from the list, type the characters that you want to embed in the text box, or click Auto Fill to include the characters that are in the selected text field. 5. Click OK.
To create the text field example application: 1. In Flash, create a new document from the Flash Lite 2.0 Generic template that you created earlier (see “Creating a Flash Lite document template (Flash Professional only)” in Getting Started with Flash Lite 2.x), and save it as textfield.fla. 2. Using the Text tool in the Tools panel, create a single-line text field across the top of the Stage. 3.
9. To use the application, press the emulator’s select key to open the text input dialog box and enter some text using your computer’s keyboard. Then click OK to close the dialog box. The text that you entered appears in the messageTxt text field in italics. Creating scrolling text (Flash Professional only) Flash Lite supports the TextField.scroll and TextField.maxscroll properties, which let you create scrolling text fields.
5. Select Use Device Fonts from the Font Rendering Method pop-up menu in the Property inspector. 6. Select Text > Scrollable to make the text field scrollable. 7. Type story in the Instance Name text box in the Property inspector. 8. Double-click inside the text field, and enter enough text so that one or more lines of text extend below its lower edge. 9. In the Timeline, select the first frame on Layer 1, and open the Actions panel (Window > Actions). 10.
Working with Text and Fonts
CHAPTER 4 4 Working with Sound, Video, and Images This chapter describes how to incorporate sound, video, and external images in your Macromedia Flash Lite application. This chapter contains the following topics: About sound in Flash Lite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Using device sound (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Using native Flash sounds . . . . . . . . . . . . . . .
Using device sound (Flash Professional only) Device sounds refer to audio that is played directly by the device, rather than by the Flash Lite player. Different devices may support different sound formats, including MIDI, MFi, or MP3. To incorporate device sounds in your Flash Lite content you can either include them within your published SWF file, or load external sound files over the network or from the device’s local file system.
To import and play a device sound: 1. Create a new document from the Flash Lite 2.0 Symbian Series 60 document template, and save it as device_sound.fla. For more information about using the Flash Lite document templates, see “Creating a Flash Lite document template (Flash Professional only)” in Getting Started with Flash Lite 2.x. 2. Select File > Import > Import to Library and browse to the Samples and Tutorials/Samples/ Flash Lite 2.
d. (Optional) To control the device sound with ActionScript, click Advanced to display the advanced sound properties options, select Export for ActionScript, and type device_sound in the Identifier text box. e. Click OK to close the Sound Properties dialog box. To play the device sound, you can either attach the proxy sound to the Timeline or use the ActionScript sound object. To use the ActionScript sound object, skip to step 6. 5. To attach the device sound to the Timeline, do the following: a.
6. To play the sound with ActionScript, do the following: a. Select the layer named Actions in the Timeline. b. Open the Actions panel (Window > Actions), and type the following code: var deviceSound:Sound = new Sound(); deviceSound.attachSound("device_sound"); deviceSound.start(); 7. Select Control > Test Movie to start the Flash Lite emulator and test your SWF file. Creating a sound bundle (Flash Professional only) Flash Lite 2.
2. From your desktop, drag the first sound file to be bundled into the Sound Bundler window. Another window appears that lists the contents of the sound bundle. The lower part of the window contains information about the sounds in the sound bundle, including sound format, size of sound data, and filename. List of files in sound bundle Information about files in sound bundle 3. Drag the rest of the sound files that you want to bundle into the window.
Playing external device sounds In addition to playing device sounds that are bundled in the published SWF file (see “Using bundled device sound” on page 48), you can also load and play external sound files. To play external device sounds you use the loadSound() method of the Sound object. As with bundled device sound, the Flash Lite player passes the externally loaded audio to the device to decode and play. The following information about playing external device sounds in Flash Lite 2.
About synchronizing device sounds with animation Device sounds in Flash Lite are always treated as event sounds. This means that you can’t synchronize device sounds with animation in the timeline in the same manner that you can with native Flash sounds. However, you can use device sounds to approximate true synchronized sound by setting the Flash Lite player’s _forceframerate property to true.
Using native Flash sounds In addition to supporting device sound, Flash Lite 2.0 also supports standard, or native, Flash sounds. Essentially, a native sound is a sound in any format that the Flash authoring tool recognizes. Native sound in Flash Lite can play either as event sound or synchronized sound (see “Using device sound (Flash Professional only)” on page 48).
The first procedure that follows explains how to enable the 8kHz sampling rate option for individual sounds in the Sound Properties dialog box; the second procedure explains how to use the Publish Settings dialog box to set this option globally for all event and stream sounds. NO TE For stream sounds, Flash always applies the global sound compression options that you specify in the Publish Settings dialog box.
To enable the 8kHz sampling rate feature globally for all native sounds: 1. In Flash Professional 8, select File > Publish Settings. 2. In the Publish Settings dialog box, click the Flash tab. 3. To enable the 8kHz sampling rate for all stream sounds in your application, do the following: a. Click Set Stream sound options. b. In the Sound Properties dialog box that appears, select MP3 from the Compression pop-up menu. The 8kHz sampling feature is available only for MP3-compressed audio. 4. c.
Using device video Flash Lite 2.0 can play device video, which refers to any video format or encoding that’s supported by the target device. To keep player size small (and to support a wide variety of video formats), Flash Lite 2.0 does not decode or render device video natively. Instead, Flash Lite 2.0 relies on the device to decode and render device video to the device’s display. For this reason, there are some limitations to using device video.
Bundling device video in a SWF file can add significantly to the size of your published SWF file, but it provides the best portability and playback reliability, because no external files need to open or stream.
To import a device video by using the Library panel: 1. In Flash, open the Library panel (Window > Library). 2. Open the Library options menu and choose New Video. The Video Properties dialog box appears. 3. In the Video Properties dialog box, select the option to bundle the source video in the SWF file, then click Import. 4. Browse to the folder that contains the device video file and select it.
2. Import the device video file named ocean.3gp located in the Samples and Tutorials/ Samples/Flash Lite 2.0/Video/ folder in the Flash Professional 8 installation folder on your hard disk. For more information about importing a device video, see “Importing device video” on page 59. A new video symbol appears in the Library panel. 3. In the Timeline, select the layer named Content, then drag an instance of the video symbol in the Library panel to the Stage. 4.
8. Drag an instance of the Play button symbol from the Buttons library to the Stage. 9. Drag an instance of the Stop button symbol from the Buttons library to the Stage. 10. Select 11. the Play button on the Stage and open the Actions panel (Window > Actions). Type (or copy and paste) the following code into the Actions panel: on(press) { myVideo.play(); } 12. Select the Stop button on the Stage and type the following code in the Actions panel: on(press) { myVideo.stop(); } 13.
You then create another placeholder video symbol and add an instance of it to the Stage. To use the placeholder video to play the device video in the library, you pass the symbol’s ActionScript identifier to the Video.play() method, as the following example shows: placeHolderVideo.play("symbol://ocean_video"); The following procedure demonstrates how to use this technique to play a single video directly from the library. To play a video directly from the library: 1.
6. To create the placeholder video clip, do the following: a. In the Library panel, click the options menu button in the panel’s title bar and select New Video. The Video Properties dialog box appears. b. In the Symbol text box, type videoHolder. c. Click OK to close the Video Properties dialog box. 7. In the Timeline, select the layer named Content, then drag an instance of the videoHolder symbol to the Stage. 8. In the Property inspector, type myVideo in the Instance Name text box. 9.
16. Publish the SWF file (File > Publish) and transfer it to your device for testing. NO TE You must test device video on the actual device; you can’t preview it in the emulator. Using external device video In addition to playing video that’s bundled in the SWF file (see “Using bundled device video” on page 58), you can also play external video files that reside on the device’s memory card or that come from a network address.
To import a device video into a video symbol: 1. Select a video symbol in the Library panel and open the Video Properties dialog box. 2. In the Video Properties dialog box, select the option to bundle the video source in the SWF file, if it’s not already selected. 3. Click Import and, in the file browser, locate the device video file to import and select it. If you don’t see the desired video file listed in the Open dialog box (or if you can see it but can’t select it), select All Files (*.
For example, the following code displays in a TextField object named mimeTypes_txt all of the video MIME types that the device supports: var mimeTypes = System.capabilities.videoMIMETypes; mimeTypes_txt.text = mimeTypes.toString(); The indices for the items contained in the System.capabilities.videoMIMEtypes array are equal to the supported device video MIME types. This provides a quick way to test whether a device supports a particular video format.
The following methods and properties of the Video object in the desktop version of Flash Player are not supported by Flash Lite 2.0: ■ Video.attachVideo() Video.clear() Video.deblocking Video.height Video.smoothing Video.width ■ Video._visible ■ ■ ■ ■ ■ For more information about using the Video object in Flash Lite, see the Video object entry in the Flash Lite 2.x ActionScript Language Reference. Loading external images In Flash Lite 2.0, as in Flash Lite 1.
In this case, only the first five images (image1.jpg through image5.jpg) will load; the last image (image6.jpg) will not load because the five connection limit is reached. One solution is to split the loadMovie() calls over multiple frames so that each frame contains a maximum of five loadMovie() calls.
Working with Sound, Video, and Images
CHAPTER 5 5 Optimizing Content for Performance and Memory Mobile devices typically have much less available memory and processing power than desktop computers. This chapter provides tips and techniques for optimizing your Macromedia Flash Lite content for file size and performance. This chapter contains the following topics: Performance optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71 Device speed and frames per second . . . . . . . . . . .
Animation guidelines When creating animated content for a mobile phone, it is important to consider the phone’s CPU limitations. The following guidelines can help prevent your Flash Lite content from running slowly: ■ Flash Lite can render vector graphics in your application at three different quality levels: low, medium, and high. The higher the rendering quality, the more smoothly and accurately Flash Lite renders vector graphics and the more processing it requires of the device’s CPU.
Vector graphics are compactly described in SWF files as mathematical equations, and then rendered at runtime by the Flash Lite player. In contrast, bitmap graphics are represented as arrays of picture elements (pixels), which require more bytes of data to describe. Therefore, using vector graphics in your application can help keep file size and application memory usage down.
3. Right-click (Windows) or Control-click (Macintosh) the bitmap’s icon in the Library window, and select Properties from the context menu to open the Bitmap Properties dialog box. 4. In the Compression pop-up menu, select one of the following options: 5. ■ Select the Photo (JPEG) option for images with complex color or tonal variations, such as photographs or images with gradient fills. This option produces a JPEG format file.
To globally set bitmap compression for bitmap images: 1. Select File > Publish Settings, and then select the Flash tab. The Flash tab displays the compression options. 2. Adjust the JPEG quality slider, or enter a value. A higher JPEG quality value provides a higher image quality but a larger SWF file size. A lower image quality produces a smaller SWF file. Try different settings to determine the best trade-off between size and quality.
Optimizing ActionScript performance Because of the processing speed and memory limitations on most mobile devices, use the following guidelines when you develop ActionScript for Flash Lite content used on mobile phones: ■ Keep the ActionScript as simple as possible. ■ Limit the number of loops that you use and the amount of code that each loop contains. ■ Stop frame-based looping as soon as it is no longer needed. ■ When possible, avoid string and array processing because it can be CPU-intensive.
■ If ActionScript code that executes on a keyframe in the timeline requires more than 1 second to complete, consider splitting up that code to execute over multiple keyframes. ■ Remove trace() statements from your code when you publish the SWF file. To do this, select the Omit Trace Actions check box on the Flash tab in the Publish Settings dialog box.
Although you cannot control how and when Flash Lite performs garbage collection, you can still free unneeded memory deliberately. For a timeline or global variables, you can use the delete statement to free the memory that ActionScript objects use. For local variables—for example, a variable defined within a function definition—you can’t use the delete statement to free an object’s memory, but you can set to null the variable that references the object.
For example, suppose your application attempts to load an XML file that’s 100 KB, but the device’s operating system has allocated only 30 KB to handle that incoming data stream. In this case, Flash Lite displays an error message to the user, indicating that not enough memory is available. To load large amounts of data, it’s best to separate the data into smaller pieces—for example, into several XML files—and make several data-loading calls for each piece.
Optimizing Content for Performance and Memory
CHAPTER 6 6 Testing Flash Lite Content (Flash Professional Only) Macromedia Flash Professional 8 includes a Flash Lite emulator that lets you test your application in the authoring tool as it will appear and function on an actual device. When you’re satisfied with the application running in the emulator, you can test it on an actual device. This chapter describes the Flash Lite testing and debugging features that are available in Flash Professional 8.
The Flash Lite emulator lets you preview your Flash Lite content as it will function and appear on an actual device. The emulator also contains controls that let you select a different test device and change the level of debugging information that the emulator generates. The emulator displays debugging messages in the Output panel to help you troubleshoot problems with your content.
The Device Settings dialog box lets you select the test devices and Flash Lite content type that you are targeting. Each combination of test device and Flash Lite content type defines a device configuration that specifies what features are available to your application, such as supported audio formats, ability to make network connections, and other features.
Testing features not supported by the Flash Lite emulator The Flash Lite emulator does not support all the features available in the standard (desktop) test window.
Interacting with the emulator (Flash Professional only) You can use your computer mouse or use keyboard shortcuts to interact with the emulator’s keypad.
Changing test devices (Flash Professional only) The Test Device pop-up menu in the emulator settings pane lets you select a different test device in which to preview your content. The devices that you selected in the Device Settings dialog box determine the test devices that are listed in the Test Device pop-up menu (see “Selecting test devices and Flash Lite content type (Flash Professional only)” on page 94).
If you haven’t yet selected any test devices before you begin testing your application, the Test Device pop-up menu says None Selected, and Flash displays a warning message where the emulator normally appears. To open the Device Settings dialog box and select your test devices without leaving the Flash Lite test window, click the message (in blue text) in the emulator pane, or select the Device Settings option in the Test Device pop-up menu.
For more information about selecting your test devices, see “Selecting test devices and Flash Lite content type (Flash Professional only)” on page 94. Setting emulator debug options (Flash Professional only) The Flash Lite emulator can send debugging messages to the Output panel while content is running. The emulator reports the following types of information to the Output panel: Trace messages that are generated by a trace() function call within your Flash Lite application.
Zooming and rotating the Flash Lite emulator (Flash Professional only) You can rotate the Flash Lite emulator, as well as zoom in and out on its contents. Rotating the emulator is useful if the content in your application is meant to be viewed in an orientation that is different from the device’s normal orientation. For example, suppose you’re creating a game for a device whose screen is oriented vertically, but the game is designed to be played with the device oriented horizontally.
For example, the following two images show the same content—a simple vector shape. The image on the left shows the content as viewed in the Flash Lite emulator at normal magnification level. The image on the right shows a portion of the same content zoomed to 400%. To zoom in or out on the Flash Lite emulator, do one of the following: ■ Select View > Magnification, and then select the desired magnification. ■ Select View > Zoom In or View > Zoom Out.
For example, the Stage area that is available to a SWF file running in full-screen mode in the stand-alone player on a Nokia Series 60 device is equal to the device’s full screen size (176 x 208 pixels). On other devices (such as those available in Japan), the Stage area that is available to a SWF file running in one of the specialized content types (such as Address Book or Screensaver) might be less than the device’s total screen size.
Unsupported ActionScript commands The Flash Lite emulator does not support the following fscommand() and fscommand2() commands: ■ ■ ■ ■ ■ ■ ■ ■ ■ FullScreen GetFreePlayerMemory GetTotalPlayerMemory Launch Quit StartVibrate GetNetworkConnectStatus GetNetworkRequestStatus GetNetworkStatus Flash Lite error and warning messages (Flash Professional only) The Flash Lite emulator generates two types of error messages while you test your content.
The other type of error message that can occur in the emulator also occurs on an actual device. These types of errors are displayed in an error dialog box that the user must close for the application to continue. The following image shows an example error dialog box as it appears in the emulator: On a device, the error dialog box that appears contains the string “Problem with content” followed by an error number. In the emulator, the error dialog box also contains a short error string.
Error number Error string Description and possible causes 6 Bad image data The SWF file contains an image that either Flash Lite, or the platform’s native image decoder, was unable to decode. 7 Bad sound data The SWF file attempted to load a sound in an unsupported format, or the sound data is corrupted. 8 Root movie unloaded This error occurs when the root (level 0) SWF file is replaced with another SWF file.
To select your test devices and Flash Lite content type: 1. In Flash, open the Device Settings dialog box, by doing one of the following: ■ Click the Device Settings button in the Property inspector (Window > Properties > Properties). ■ Select File > Device Settings. You can also open the Device Settings dialog box when you test your application in the emulator. For more information, see “Using the Flash Lite emulator (Flash Professional only)” on page 84. 2.
If a device doesn’t support the selected content type, it appears dimmed. (On Macintosh systems, the icon next to the name of each device is dimmed, but not the text itself.) If none of the devices in a folder support the selected content type, the folder itself is dimmed. You can add dimmed devices to your list of test devices, but they won’t be available when you test your application in the emulator. Dimmed devices don’t support the selected content type. 4.
5. Click Make Default to set the default device settings to the currently selected content type and test devices. Flash automatically applies the default device settings to any new document whose SWF file’s publish version is set to Flash Lite 1.0, 1.1, or 2.0. 6. Click OK to close the Device Settings dialog box. The devices and content types listed in the Device Settings dialog box are loaded from a local XML database that is installed with Macromedia Flash Professional 8.
Flash Lite supports the following content types: Flash Lite content Description type Availability Address Book Uses Flash Lite to let users DoCoMo and VodafoneKK associate a SWF file with an entry (Japan only) in their device’s address book application. Alarm Uses Flash Lite to let the user select a SWF file to play for the device’s alarm. Browser Uses Flash Lite to render Flash DoCoMo, KDDI, and content embedded in mobile web VodafoneKK (Japan only) pages and viewed in the device’s web browser.
Flash Lite content Description type Availability Image Viewer Use the Image Viewer application DoCoMo (Japan only) that lets the user manage and preview multimedia files on the device, including SWF files. Incoming Call Uses Flash Lite to display an animation when the user receives a call. Mailer VodafoneKK (Japan only) Uses Flash Lite to display an animation when the user sends or receives an e-mail message. Multimedia Uses Flash Lite to preview SWF files (as well as other multimedia formats).
Flash Lite content Description type Availability Sub LCD Uses Flash Lite to display content KDDI (Japan only) on the external or secondary screen available on some flip phones. UILauncher Uses Flash Lite for the device’s application launcher. Wake Up Screen Uses Flash Lite to display an DoCoMo (Japan only) animation as the phone is starting.
Flash Lite platform capabilities (Flash Professional only) Each combination of target device and Flash Lite content type defines a set of available Flash Lite features, such as navigation type, supported image and sound formats, or input text support.
The following table describes the Flash Lite platform capabilities as they are reported in the Output panel when you test your application in the emulator: Capability name Description and possible values CodePage Specifies the code page that the device uses. Values are in the ISO-639 language code format (for example, en for English and zh-TW for Traditional Chinese). DeviceImageFormats Lists the image formats (in image/ImageType format) that the device supports natively.
Capability name Description and possible values FSCommand Indicates how frequently Flash Lite processes fscommand() or fscommand2() function calls. Valid values are as follows: OnePerKey: Only one fscommand() call is allowed for each keypress. OnePerKeyPerFrame: Only one fscommand() call is allowed per event handler or per frame. All: No restriction on how frequently fscommand() can be called. None: The fscommand() function is not supported.
Capability name Description and possible values LoadMovie Indicates how frequently Flash Lite processes loadMovie() function calls. Valid values are as follows: OnePerKey: Only one loadMovie() call is allowed for each keypress. OnePerKeyPerFrame: Only one loadMovie() call is allowed per event handler or per frame. All: No restriction on how frequently loadMovie() can be called. None: The loadMovie() function is not supported.
Capability name Description and possible values NavigationType Indicates the navigation mode that the platform supports: two-way, four-way, or four-way with wrap-around. For more information about navigation modes, see “Default navigation modes” on page 14. Valid values are as follows: 2Way: Up and down arrow keys supported only. 4Way: All four arrow keys (up, down, left, and right) are supported for navigation. 4WayWrapAround: Same as 4Way except that focus wraps around to the top of the display.
About playing a device video in the emulator The Flash Lite player uses the device’s default video handler application to play video content in your SWF file, rather than decoding the video natively. This practice lets Flash Lite developers use any video format that the target device supports, such as 3GPP, MPEG, or AVI. For more information about using video in Flash Lite, see “Using device video” on page 58.
APPENDIX A A Warning and Error Messages (Flash Professional Only) This appendix lists the possible information and warning messages that the Macromedia Flash Lite emulator might generate while you’re testing your Flash Lite application. For more information about these warning messages, see “Setting emulator debug options (Flash Professional only)” on page 88.
Error code Message Description FTPA004 loadMovie is ignored. The emulator detected a loadMovie() function call, which is not supported by the selected test device and content type. No modifications are made to the device-specific SWF file—this is just a warning. FTPA005 The call to GetURL for URL was ignored because there was more than one request per keypress.
Error code Message Description FTPA015 The call to loadMovie for URL was Flash Lite allows only one loadMovie() ignored because there was more function call per keypress; the than one request per keypress. emulator detected that there was more than one loadMovie() so only the first command is processed—the others are ignored. FTPA016 The call to loadMovie for URL was The currently selected test device and content type process only loadMovie() ignored because it was not associated with a keypress.
Error code Message Description FTPA020 The call to FSCommand with arguments command-arguments was ignored because it was not associated with a keypress. The currently selected test device and content type process only fscommand() function calls that result from users pressing a key on their device. The emulator detected that your application made a call to fscommand() that wasn’t associated with a keypress. FTPE001 The key will not be processed: keyname ASCII Value: value.
Error code Message Description FTPS023 MP3 sounds not supported for the The emulator detected that the SWF selected content type on this file contains a native (nondevice) device. sound compressed with MP3 compression, which is not supported by the selected content type on this device. No modifications are made to the device-specific SWF file—this is just a warning.
Error code Message Description FTPS031 More than one instance of URL Request calls found, only one allowed per keypress/frame. Flash Lite allows only one getURL() function call per keypress or frame; the emulator detected that there was more than one getURL() so only the first command is processed—the others are ignored. FTPS032 A call to GetURL(URL) found, limitations might apply.
Error code Message Description FTPS038 The call to StartVibrate was ignored because there was more than one request per frame or event. Flash Lite allows only one fscommand2("StartVibrate") call per keypress or frame; the emulator detected more than one, so only the first command is processed—the others are ignored. FTPS039 FSCommand2 SetInputTextType The SetInputTextType command is not (command-arguments) found, not supported in the emulator.
Error code Message FTPS068 SMAF (MA-3) sounds not The emulator detected a SMAF supported for the selected content (MA-3) device sound, which is not type on this device. supported by the selected content type on this device. FTPS069 SMAF (MA-5) sounds not The emulator detected a SMAF supported for the selected content (MA-5) device sound, which is not type on this device. supported by the selected content type on this device.
Error code Message Description FTPS101 None of the formats in the sound bundle are supported on this device. Indicates that none of the device sounds in a sound bundle are supported by the selected content type on this device. FTPS102 SMAF sound playback failed. The emulator was not able to play the SMAF sound. FTPS105 This SWF is not in Flash Lite format.
Warning and Error Messages (Flash Professional Only)
Index A F application modes, in Flash Lite 97 Flash Lite emulator changing test devices 86 debug options 88 features unsupported by 84 interacting with 85 previewing applications with 84 rotating 89 warning and error messages 92, 107 zooming 89 font outlines, embedding in SWF files 41 font rendering methods, applying to text fields 38 B button events 21 C classes, excluding built-in classes 79 content types in Flash Lite, described 97 D determining supported audio file formats 54 device settings about
M menus, creating with buttons 23 N native sound about 55 re-sampling at 8kHz 55 navigation.