Contacts Demo – S60 Platform Services API example with Flash Lite

Here is my first Nokia S60 Platform Services API test with Adobe Flash Lite. This demo is designed to run 360x640 screens (like Nokia 5800 and N97). Application first loads contacts name, phone number, work and home addresses and shows all informations nicely in interactive scrollable menu.

Contacts Demo scr 1 Contacts Demo scr 2

 
// create contacts service object
var contact = new Service("Service.Contact","IDataSource");
var inParams = {Type:"Contact"};
// get contacts from phone
var outParams = contact.GetList(inParams);
if (outParams.ErrorCode == 0) {
  var outList = outParams.ReturnValue;
  var outputEntry = null;
  var i:Number = 0;
  var step:Number = 40;
  do {
    outputEntry = outList.next();
    if (null != outputEntry) {
    // add a new contact to container list
    i++;
    var mc:MovieClip = container_mc.attachMovie("ContactItem","Contact"+i,
      container_mc.getNextHighestDepth());
    container_mc.addMC(mc);
    container_mc["Contact"+i].init(outputEntry, container_mc, i,
    contactheader_fmt, contactdata_fmt);
    container_mc["Contact"+i]._y = (i-1)*step;
  } else { break; }
} while (true);
  // show contact list
  gotoAndStop("show");
} else {
  info_txt.text = outParams.ErrorCode;
}

Details of contact information are displayed when user presses contacts name. Multiple contacts can be open at the same time. If contact has work or home address, this demo applications can load static JPG from Google Maps to show address in a map.

Contacts Demo scr 2 Contacts Demo scr 3

 
// data objects to server and back
var sendDataLV:LoadVars;
var loadDataLV:LoadVars;
// show map loading info to user
var info_mc:MovieClip;
 
//start loading request
function showInMap(street:String,city:String,country:String):Void {
  sendDataLV = new LoadVars();
  loadDataLV = new LoadVars();
  info_mc = _level0.attachMovie("info","info_mc",
    _level0.getNextHighestDepth());
  info_mc._x = 5;
  info_mc._y = 70;
  loadDataLV.onLoad = latLonLoaded;
  sendDataLV.address = street+" "+city+" "+country;
  _level0.info_mc.text_txt.text += "street : " + street + "\n";
  _level0.info_mc.text_txt.text += "city : " + city + "\n";
  _level0.info_mc.text_txt.text += "country : " + country + "\n";
  // send lat and lng request to server
  sendDataLV.sendAndLoad(phpUrl,loadDataLV,"POST")
  _level0.info_mc.text_txt.text += "Get lat and lng...\n";
  back_mc._visible = true;
}
 
// lat and lng returned from server
function latLonLoaded(ok:Boolean):Void {
  if (ok) {
    if (loadDataLV.latitude != undefined &&
        loadDataLV.longitude != undefined) loadMap();
    else _level0.info_mc.text_txt.text += "No Lat and Lng!\n";
  } else {
    loadDataLV = null;
    sendDataLV = null;
    _level0.info_mc.text_txt.text += "Can't connect server to get Lat and Lng!\n";
  }
}
 
// start loading map from Google
function loadMap():Void {
  // show info
  _level0.info_mc.text_txt.text += "Loading map...\n";
  _level0.info_mc.text_txt.text += "Latitude: "+loadDataLV.latitude+"\n";
  _level0.info_mc.text_txt.text += "Longitude: "+loadDataLV.longitude+"\n";
  // map size
  var mapWidth = 350;
  var mapHeight = 520;
  // lat and lng
  var lat = loadDataLV.latitude;
  var lng = loadDataLV.longitude;
  var apiKey = 'API_KEY';
  // JPG loader
  var loader:MovieClipLoader = new MovieClipLoader();
  // url
  var mapUrl:String = 'http://maps.google.com/staticmap?center=' +
    lat + ',' + lng + '&format=jpg&zoom=15&size=' +
    mapWidth + 'x' + mapHeight + '&key=' + apiKey +
    "&markers="+lat+","+lng+","+"greena";
  // start map load
  loader.loadClip(mapUrl, _level0.info_mc.map_mc);
  _level0.info_mc.text_txt.text += "Loading, please wait...\n";
}

Contacts Demo scr 4 Contacts Demo scr 5

Look more detailed informations in source codes:
- ContactsDemo_PTM.zip (include CS4 FLA, AS class files and PHP files)
- ContactsDemo_PTM.zip (includes only CS3 FLA):
- ContactsDemo.fla
- Contact.as
- Menu.as
- and a few PHP files to get Lat and Lng values from Google Maps.

23 Responses to “Contacts Demo – S60 Platform Services API example with Flash Lite”


  1. 1 Li YongFei

    Hi,Pasi

    That’s great,Thanks for your share.

  2. 2 Hemanth Sharma

    This is great.

    Very interesting and nice. Thanks for sharing.:)

  3. 3 vivek

    cool :)

    Cheers

  4. 4 Bill Perry

    Great article Pasi! Thanks for sharing with the community.

  5. 5 Marcos

    Great example Pasi. Thanks for share this high quality stuff!

    I have done some similar research for a spanish community event, and it’s great to see this kind of posts! I’m sure there’ll be a lot of flash lite developers looking for this info in the near future :)

  6. 6 ptm

    Thank you all for your comments. I will try to find time to test all other S60 Services API features in near future. I will write all my experiments here in my blog.

    Pasi

  7. 7 Christian

    Unable to open the ContactsDemo.fla although I have CS3. What’s wrong?

  8. 8 ptm

    Christian,

    I used CS4 file format with it. I will try to put CS3 format source available tomorrow.

    Pasi

  9. 9 Christian

    Thank you, Pasi.
    This means, CS4 files can not be expected to be compatible to CS3 files? Dear folks from Adobe, that’s bad!

  10. 10 ptm

    Christian,

    now there is CS3 FLA available also in my blog. Flash CS4 can save Flash files in CS3 or CS4 format.

    Pasi

  11. 11 Christian

    Thank you!

  12. 12 rohitmah

    Flash Lite crashes after I select “Allow reading of user data”. Any idea why? The application compiled fine in CS4

  13. 13 ptm

    rohitmah,

    you are using 5th edition phone, right? Do you have *a lot of* contacts in your phonebook? Like you know, this is just a sample and there isn’t handled any memory issues right now. I have about 120 contacts in my phonebook and this sample takes about 4MB memory in my Nokia 5800 (which seems to get about 20MB for Flash Lite).

    Pasi

  14. 14 serhangurbuz

    Help! The application stopped on second frame. Anybody knows reason? And there is no modification in it. Just shown Loading

  15. 15 frustr8ed

    Hi, which flash lite version does this work? Is this possible in FL2.0?

  16. 16 ptm

    frustr8ed,

    Service APIs only work on S60 5th Edition devices that support Flash Lite 3.0 or newer.

    Pasi

  1. 1 Flash Lite codes: Contacts Demo | Adobe Flash Lite
  2. 2 S60 Platform Services API with Flash Lite at Flash Lite Hub
  3. 3 .byte-sm’s blog - Leonardo Risuleo » Contacts Demo - Flash Lite & S60 Platform Services API
  4. 4 Flash Lite Contacts Demo using S60 Platform Services API | biskero
  5. 5 Demo Flash Lite + Nokia Services API | BlocketPc :: Flash Lite y Mobile Web
  6. 6 Hemanth Sharma's Tech Blog
  7. 7 PTM - Pasi Manninen - Flash, Flash Lite and Flex Developer

Leave a Reply





Get Adobe Flash playerPlugin by wpburn.com wordpress themes