Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 05:34, 14 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Communicating with Flash Lite from JavaScript in a widget (WRT)

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Code Example
Source file:
Created: raheal_akh (05 Dec 2007)
Last edited: hamishwillee (14 May 2013)
Featured Article
21 Sep


  • Knowledge of Flash Lite from Adobe and JavaScript.


Flash Lite


1) Create a Flash file.

In Frame 1 (ActionScript layer):

Define the following variables in the ActionScript window.

  var total_ram;
  var free_ram;

In Frame 5:

Create a new layer that holds the textboxes on the screen (objects layer).

Create two textboxes on the screen in a separate layer and assign the following variables in ‘var’ for the textboxes.


Next, create a movie clip to indicate the memory level on the screen.


Note: When converting to symbol, set the registration as shown in bottom the picture.


In Frame 5 (ActionScript layer):

    //Set the Interval of updating text boxes on the screen.
var intervalId = setInterval( updateScreen, 1000 ); //1 Second
function updateScreen()
if(total_ram != undefined && free_ram != undefined )
total_ram_txt = total_ram + " M"; //set Total ram in textfield
free_ram_txt = free_ram + " M"; //set Free ram in textfield
_root.mem_lvl_mc._height = (free_ram*50/total_ram); //Update Level on the screen

The SetInterval() function is a built-in ActionScript function that periodically calls a piece of code or function after the set interval.

The Flash part is now ready. Publish the .swf file and name it memInfo.swf.


Now create a .html file with the following content.

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"">
  <html xmlns="">
      <title>Memory Info</title>
      <script language="javascript">AC_FL_RunContent = 0;</script>
      <script src="AC_RunActiveContent.js" language="javascript"></script>
  <BODY BGCOLOR="#FFFFFF" onload = "load();"> 
      <embed id="systeminfo" type="application/x-systeminfo-widget" hidden="yes"></embed>
      <script language="javascript">
	    if (AC_FL_RunContent == 0) {
		 alert("This page requires AC_RunActiveContent.js.");
	    } else {
			'codebase', '[http]://,0,0,0',
			'width', '240',
			'height', '320',
			'src', 'network_signal240x320',
			'quality', 'high',
			'pluginspage', '',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', 'memInfo',
			'bgcolor', '#ffffff',
			'name', 'memInfo',
			'menu', 'true',
			'allowFullScreen', 'false',
			'movie', 'memInfo',
			'salign', ''
			); //end AC code
	     ID=memInfo align="middle">
	     <param name="allowScriptAccess" value="sameDomain" />
	     <param name="allowFullScreen" value="false" />
	     <param name="movie" value="memInfo.swf" />
	     <param name="quality" value="high" />
	     <param name="bgcolor" value="#ffffff" />
	      quality="high" bgcolor="#ffffff" 
              pluginspage="" />

Note: {{{1}}} is used to allow the widget to gain access to system attributes such as battery level, signal level, available memory, and so on. This value needs to be defined under the <body> tag.

The value inside the ‘name’ property (for example, “memInfo”) of the Flash embedded object will be used by JavaScript to communicate with Flash.


In the JavaScript file:

var sysinfo = null;
var drives = 0;
var totalRamSize;
var freeRamSize;
var space;
var loop = 0;
function load()
sysinfo = document.embeds[0]; //Must for accessing system attributes
function Runtimer()
//Calls itself every 2 second and calls AC_communicateWithFlash() function
t=setTimeout("Runtimer()",2000); //2 Second
if(loop != 0)
{ AC_communicateWithFlash();}
loop = 1;
function checkRamSpace()
// get total RAM size in bytes
totalRamSize = sysinfo.totalram;
space = Number(Number(totalRamSize) / Number(1048576)); //MB
totalRamSize = space.toFixed(2);
// get free RAM size in bytes
freeRamSize = sysinfo.freeram;
space = Number(Number(freeRamSize) / Number(1048576)); //MB
freeRamSize = space.toFixed(2); //Display 2 Decimal Place
function getFlashMovieObject(movieName)
if (window.document[movieName])
return window.document[movieName];
if (navigator.appName.indexOf("Microsoft Internet")==-1)
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
return document.getElementById(movieName);
function AC_communicateWithFlash()
//this function checks for Current Ram Space and Drives Space
//and sets the values inside flash.
//memInfo defined in HTML file used for referencing flash Object
var flashMovie=getFlashMovieObject("memInfo");
//following steps assigns the JAVASCRIPT variables values to flash variables placed on
the root timeline.
flashMovie.SetVariable("/:free_ram",freeRamSize );


Download the source code

The package contains the Flash source file, the JavaScript file, and other related material.

See also


--raheal_akh 15:42, 5 December 2007 (EET) RAHEAL AKHTAR

This page was last modified on 14 May 2013, at 05:34.
183 page views in the last 30 days.