Channels ▼


Flash Lite: Graphics for Mobile Devices

Source Code Accompanies This Article. Download It Now.

Adding the Final Code

The Flash Lite 1 function call LoadVariables retrieves data from the server. You can use the Help functionality of Flash Professional 8 to view how this function (or any other Flash Lite function) is used. In the Actions panel (below the Stage), click Global Functions, click Browser/Network, right-click LoadVariables, and select View Help from the pop-up menu.

Add Listing Four (a) to the ActionScript layer of frame frLoad. This initializes the necessary variables and starts the data download. Listings Four (b) and (c) go to the ActionScript layers of frame wait1 and frame 7. These two frames are displayed in sequence until the data has been fully downloaded. This lets you create an animation for users to watch while data is being downloaded, and to let them know that the application is still active.

// initialize and clear the variables
for (i=1;i<5;i++)
    eval("name" add i) = "";
    eval("value" add i) = "";
url = "<URL to your PHP-script page>?query=" add target add "&year="
       add statYear;
LoadVariables(url, _root);

if (loaded eq "true") 
    if (noData eq "true")


fscommand2("SetSoftKeys", "Options", "Back");

on(keyPress "<PageDown>")
Listing Four

Listing Four (d) has to be placed in the ActionScript layer of frames homeruns and salaries. This command lets the system listen when users press softkeys; the application is using the right softkey for returning to the selection page (note the Back-label on the lower right corner of the result screens). However, because this is not enough to process the softkey presses, you need to create a button (you can drag a copy of the btInvisible from the library on the stage) on both of the frames. Place the button outside the display area, which lets the button listen to the key presses although users can't select it. Place Listing Four (e) on the button.

Your application should now be fully functional. Test the movie in the simulator of the IDE, then on a real device. For example, if you have an S60 handset, you can transfer the nettest.swf file to the phone using the File manager of the PC Suite application.

The folders to store the Flash Lite applications vary from phone to phone. On S60 3rd Edition devices you should transfer the file to the /Data/Others folder. On older S60 phones the correct directory is /documents/Flash. With Series 40 phones, you do not need to worry about where to store the file because the phone automatically stores it in the correct folder.

Where To Go From Here

This application demonstrates the development and testing of a Flash Lite application that retrieves text data from a server. You can use fancy graphics to create a more appealing UI that looks less like a series of plain forms. Another addition could be a splash sequence. For example, generate a splash graphics in the first frame of the application and extend that keyframe for a number of frames.

Adding audio-visual items also makes the application more appealing. Sounds would likely play a minor role in this kind of application, although some game-related audio clips would spice up the pages. Flash Lite supports MP3 on some phones. Photos of baseball players would also be nice, although when working with Flash Lite 1.1, you'd need to convert photos to Flash Lite movies, which could then be retrieved from the server using the LoadMovie() function.

Another enhancement is to retrieve more complex statistics. This example only shows a couple of top players for a certain year. You could create an interface that shows the fielding of players for different teams and years using a field diagram. Or you could calculate some advanced player statistics based on the batting information.

If the data to be downloaded to the application is already in XML format (RSS feeds, for example), you could use Flash Lite 2's XML capabilities. While this increases the size of downloadable data and makes the application more costly to users, the XML approach also makes it easier to create more compelling data rich applications. In addition, you could use other Flash Lite 2 features, such as greater control of the animations from ActionScript and MediaPlayback API.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.