One of the biggest issues in delivering Flash content is that users must open the Flash Lite Player or use the File manager or Gallery to open the file. The Flash content is not treated as other applications. It does not have an icon and the application shortcut cannot be added to any quick access menus. Another disadvantage is that any external resources need to be delivered separately, which is tedious for the user. In S60 this can be tackled by creating a Symbian Installation System (SIS) file that simply extracts the contents to the correct folder. However, SIS files must be signed and the target folder may vary between S60 platform versions. To solve these issues, you can package Flash content inside widgets.
For information about Flash support in Web Runtime, see Web Runtime versions and device support. You can package Flash content in widgets in the following ways:
Embed the Flash content in the widget.
Replace the main HTML page with the Flash content.
Use the meta refresh tag in the HTML file.
For an example, see How to package Flash content in a Widget on the Forum Nokia Wiki.
Create a Cascading Style Sheet (CSS) file. When you create full-screen Flash content, you mainly need the CSS file to set the color of the background and to make sure the full-screen Flash content is positioned correctly.
body {
background: rgb(0,0,0);
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
margin: 0px;
overflow: hidden;
}Create JavaScript to set the navigation mode. The following example embeds a single JavaScript command in the main HTML file. This tells WRT to set the navigation mode to tab navigation. You can also use cursor navigation.
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
widget.setNavigationEnabled(false);
//-->
</SCRIPT>Embed the Flash content.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="238" height="318" id="MyFlash" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="MyFlash.swf" /> <param name="loop" value="false" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="bgcolor" value="#ffffff" /> <embed src="MyFlash.swf" loop="false" menu="false" quality="high" wmode="opaque" bgcolor="#ffffff" width="238" height="318" name="Finish" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
If you do not know the screen sizes of the devices beforehand, you can use some JavaScript in your WRT widget to detect the screen size and use that information to optimize the SWF for the available real estate through variables, or by using multiple SWF files. You can also deal with this issue in the SWF file. For more information, see Dynamic Layout control for Flash Lite on the Forum Nokia Wiki.
WRT supports interaction between Adobe ActionScript and JavaScript on devices that have Flash Lite 3.0 and later. This provides a way to pass ActionScript commands from the Flash content to the widget and use JavaScript commands to access and control the Flash content. This includes operations such as registering for a callback from JavaScript to ActionScript and passing objects from ActionScript to JavaScript.
There are several way to pass commands between ActionScript and JavaScript:
Using Flash methods, which are JavaScript functions that are specific to Flash movies. For information see, the Adobe Macromedia Flash Support Center Web pages Flash Methods and Getting and setting properties.
Sending FSCommand actions from Flash to JavaScript
via DoFSCommand. For information, see the Adobe Macromedia
Flash Support Center Web page fscommand.
Via an external API (ExternalInterface). For information,
see the Adobe Developer Connection Web page Using the External API for Flash–JavaScript Communication.
Although there are several ways to do so, the best way to communicate
between ActionScript and JavaScript in WRT is via the ExternalInterface class.
For an example of communication between JavaScript and the ActionScript, see An example
of communication between JavaScript and Adobe Flash Player on the Adobe
Developer Connection website.
Note: You should avoid embedded Flash content that involves keyboard focus, such as interactive elements. Running such content on non-touch devices may make it difficult for the mobile device user to leave the Flash content and return to the widget. If you want to add interactive elements such as onscreen controls, they should be done using HTML and JavaScript. For example, you should define buttons such as play and pause using HTML and then use JavaScript to pass the play and pause commands to the Flash content.
Specify the SWF file
as the MainHtml file in the info.plist file.
<key>MainHTML</key> <string>myFlash.swf</string>
The .swf is launched in the Flash Lite player and when you exit it, the application asks if you want to save it. It then opens an empty widget screen (plain white).
To avoid the blank screen, edit the Flash file and hide the softkeys. The only way to exit your application is to press the end key.
//Hide softkeys
fscommand2("FullScreen", true);
//Replace the dummy values to use the Flash Player softkey labels.
fscommand2("SetSoftKeys", "right dummy", "left dummy"); Add a meta refresh tag
in the head element of the main HTML file. You still get
a blank page but this time you can edit its contents. You can, for example,
use the page to direct the user to your home page and provide them with additional
information. In the following example, the 0 before the URL means that there
is no timeout, which makes the functionality more stable in some devices.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SWF Launcher</title>
<META http-equiv="REFRESH" content="0; url=MyFlash.swf">
<script type='text/JavaScript'>
function killWRT(){
var WRT = window.open("", "_top");
WRT.close();
}
</script>
</head>
<body>
<div align="center">
<br><br>
You can find more information at <a href="http://www.forum.nokia.com">Forum Nokia</a>.
<br>
<input type="button" value="Close this window" onclick="killWRT()" />
<br><br>
<b>Thank you for choosing our Flash Lite application.
<br><br>
- the team -</b>
</div>
</body>
</html>Note: You can disable the softkeys and close the application with the end key, as shown in the previous example.