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 over the next few weeks. Thanks for all your past and future contributions.

Archived:Simulating Arrays in better way in Flash Lite 1.1

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 ExampleArticle
Created: sangramp (26 Apr 2008)
Last edited: hamishwillee (14 May 2013)



Even though the latest version of Flash Lite supports arrays, the market is already populated with devices supporting Flash Lite 1.1 only. And Flash Lite 1.1 does not support arrays. So when designing the Flash Lite application, target device plays a vital role. There is traditional approach to simulate arrays by creating a bunch of variables and accessing them using ‘eval’. This approach is memory consuming and a bit odd to use. So we can simulate the array in a better way as follows.

Source Code

Define Length of each item in array

Define the length of each item in the array. Make sure to mention each individual item with 'counter' numbers/characters.

counter = 2; //This is the length of each item.

Eg.: If counter is set to 2, the elements will be 01,02,03. If counter is set to 3, the elements will be 001,002,003.

Define Array

Define the array as a string and individual items of the array in the sequence. Add the ‘&&’ character at the end of the string as a delimiter.

option_0 = "010203040607081213141516171819202122242526272829303132&&";

Here the elements are 01,02,03 as counter is set to 2.

Define 'fnGetLength' Function

Define a ‘FunctionClip’ named ‘mcFunction’ and add the following code in the frame labeled as ‘fnGetLength’. This function will return the length of the array.

nLength = 0;
start_ind = 1;
//Set the starting index as 1 always
str = "a";
//Define the str to any value for initilisation
while (str ne "&&") {
str = substring(_parent.option_0, start_ind, _parent.counter);
start_ind = start_ind+_parent.counter;
if (str != 0) {
nLength = nLength+1;
//The above while loop will iterate through the array option_0'.The 'substring'
//function will return the array element as we give the offset and the length of
//the individual element. The loop will iterate till it encounters a 'Delimiter'.
trace("Length Of Array is:: "+nLength);

On the main timeline you can access this function as follows:


Define 'fnGetElementbyIndex' Function

In the same ‘FunctionClip’ named ‘mcFunction’ add the following code in the frame labeled as ‘fnGetElementbyIndex’. This function will return the element of the array, given the item index as ‘nElementIndex’.

nStartIndex = (_parent.nElementIndex*Number(_parent.counter))+1;
//Depending upon the element to access the offset will be calculted
str = substring(_parent.option_0, nStartIndex, _parent.counter);
trace("ELEMENT:: "+str);

On the main timeline you can access this function as follows:

First set the index number required

nElementIndex = 0;


You can download the source code at Simulating Arrays in Flash Lite 1.1.

This page was last modified on 14 May 2013, at 06:21.
24 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.