Archived:Contacts Component for Flash Lite
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.
This document explains how to use Flash Lite Contacts data component and API.
Article Metadata
Contents |
Introduction to the Contacts component
The Contacts component uses the Nokia Platform Services Contacts API to read and filter a mobile device’s contacts data. The received data is provided in an array of n items, in format {Label, Value}, which is broadcast using the EventDispatcher for all listening objects.
Requirements
- Adobe Flash Professional CS3 or CS4
- A device supporting S60 Platform Services, e.g. S60 5th Edition device. See http://www.developer.nokia.com/Devices/ for more information.
Download
Contacts component is included in the Nokia Developer Flash Lite Components package.
Installation
Installation of the Contacts component is easy. Execute the components MXP file and follow the simple instructions in Adobe Extension Manager to complete the installation process. Restart Adobe Flash CS4 after installation.
Note: Component FLA and AS files should appear in the directories [INSTALL PATH]\Flash CS4\en\Configuration\Components\Nokia Developer and [INSTALL PATH]\Flash CS4\en\Configuration\Classes\com\forumnokia. In some setup environments, the files may appear under the wrong language directories (for example, fi instead of en). In such cases, the files should be manually moved to the correct directories as specified above.
Preparations
- Create a Flash Lite Project. Open the Component panel (Ctrl/Apple key + F7) and drag the Contacts component onto the stage. Assign a unique instance name for the object using the properties panel (Ctrl/Apple key + F3). Contacts can now be read using the ActionScript API call getContactsData().

- The component sends an event when the contacts data is fully received. For receiving the event and reading, see the section Adding a listener, below.
Skins and assets
The data component does not have any visual elements, except the icon
, which is not visible at runtime.
Inspectable parameters
These component parameters can be changed via the Component Inspector panel (Shift + F7). All inspectable parameters can also be controlled via ActionScript with the component APIs.
| Parameter | Description | Value |
|---|---|---|
| Filtering | Enables filtering to retrieve only certain contact fields, otherwise all contact data is received. | By key values / Disabled; default is By key values |
| Filtered contact fields | This value defines which contacts fields (keys) will be received. Only required if filtering is used. | Key values are defined in the Supported contact keys section in the Flash Lite Developer’s Library; default is FirstName, LastName |
| Sorting order | Sorting order | Ascending/Descending; default is Ascending |
Contacts Component ActionScript API
Setting a data filter
public function setFilterValue( key:String ): Void;
This function sets the data filtering according to given key(s), defined in: Supported contact keys section in the Flash Lite Developer’s Library.
Setting the sorting order
public function setSortingOrder( order:String ): Void;
The sorting order can be “Ascending” or “Descending”.
Getting the DataLoad event
public function onReceivedDataEvent(): String;
Returns the event name, which this component will dispatch after receiving data. By default, the name is “onContactsDataLoadEvent”.
Reading contacts data
public function getContactsData(): Void;
Starts reading contacts data using the S60 Platform Service API (uses the asynchronous method for reading), and dispatches an event when the data is read.
Error handling
public function lastError(): Number;
If there was no error in the last call of getContactsData(), the error value is 0.
Error values are defined in the Supported contact keys section in the Flash Lite Developer’s Library.
Note: The returned error value is “undefined” until the component has finished reading data.
Adding a listener
public function addEventListener(event:String, listenerFunction:Object): Void;
The Contacts component dispatches an event when the data is ready. The event can be listened for by creating a listener function and calling the API method addEventListener(). Delegate should be called when specifying the scope in which to run the listening function.
Simple use:
var event_name:String = myContacts.onReceivedDataEvent();
myContacts.addEventListener( event_name, myEventHandler );
function myEventHandler( evt ){
myData = evt.ContactsData;
//handle ContactsData here (refer to Nokia Developer documentation)
}
// Read the contacts data (myEventHandler gets invoked)
myContacts.getContactsData();
Advanced use:
This example uses Delegate to make sure that the correct event is received here. It also checks for errors and parses the received data.
var event_name:String = myContacts.onReceivedDataEvent();
myContacts.addEventListener( event_name, Delegate.create( this, myEventHandler) );
var receivedItems:Array = [];
function myEventHandler( eventObj:Object ):Void {
switch( eventObj.type )
{
case event_name:
// Add functionality here
// First check for error
if( myContacts.lastError() == 0 )
{
for (i = 0; i < eventObj.ContactsData.length; i++)
{
receivedItems.push( eventObj.ContactsData[i].FirstName + " "
+ eventObj.ContactsData[i].LastName; );
}
// Copy received data into List UI component
list_mc.populateData( receivedItems );
}
else
{
// Handle the error here
}
break;
default :
break;
}
}
// Read the contacts data (myEventHandler gets invoked)
myContacts.getContactsData();
Removing the listener
public function removeEventListener(event:String, listenerFunction:Object): Void;
Tells the component to stop listening for events.



Flotron -
Is there any example fla how to load contact number to dynamic text input?flotron 03:45, 30 August 2012 (EEST)
Hamishwillee - Search the wiki
Suggest you try searching: http://www.developer.nokia.com/Community/Wiki/index.php?title=Special%3ASearch&redirs=0&search=Flash+Contacts&fulltext=Search&ns0=1hamishwillee 07:25, 4 September 2012 (EEST)