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

  1.  
  2. // create contacts service object
  3. var contact = new Service("Service.Contact","IDataSource");
  4. var inParams = {Type:"Contact"};
  5. // get contacts from phone
  6. var outParams = contact.GetList(inParams);
  7. if (outParams.ErrorCode == 0) {
  8. var outList = outParams.ReturnValue;
  9. var outputEntry = null;
  10. var i:Number = 0;
  11. var step:Number = 40;
  12. do {
  13. outputEntry = outList.next();
  14. if (null != outputEntry) {
  15. // add a new contact to container list
  16. i++;
  17. var mc:MovieClip = container_mc.attachMovie("ContactItem","Contact"+i,
  18. container_mc.getNextHighestDepth());
  19. container_mc.addMC(mc);
  20. container_mc["Contact"+i].init(outputEntry, container_mc, i,
  21. contactheader_fmt, contactdata_fmt);
  22. container_mc["Contact"+i]._y = (i-1)*step;
  23. } else { break; }
  24. } while (true);
  25. // show contact list
  26. gotoAndStop("show");
  27. } else {
  28. info_txt.text = outParams.ErrorCode;
  29. }

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

  1.  
  2. // data objects to server and back
  3. var sendDataLV:LoadVars;
  4. var loadDataLV:LoadVars;
  5. // show map loading info to user
  6. var info_mc:MovieClip;
  7.  
  8. //start loading request
  9. function showInMap(street:String,city:String,country:String):Void {
  10. sendDataLV = new LoadVars();
  11. loadDataLV = new LoadVars();
  12. info_mc = _level0.attachMovie("info","info_mc",
  13. _level0.getNextHighestDepth());
  14. info_mc._x = 5;
  15. info_mc._y = 70;
  16. loadDataLV.onLoad = latLonLoaded;
  17. sendDataLV.address = street+" "+city+" "+country;
  18. _level0.info_mc.text_txt.text += "street : " + street + "\n";
  19. _level0.info_mc.text_txt.text += "city : " + city + "\n";
  20. _level0.info_mc.text_txt.text += "country : " + country + "\n";
  21. // send lat and lng request to server
  22. sendDataLV.sendAndLoad(phpUrl,loadDataLV,"POST")
  23. _level0.info_mc.text_txt.text += "Get lat and lng...\n";
  24. back_mc._visible = true;
  25. }
  26.  
  27. // lat and lng returned from server
  28. function latLonLoaded(ok:Boolean):Void {
  29. if (ok) {
  30. if (loadDataLV.latitude != undefined &&
  31. loadDataLV.longitude != undefined) loadMap();
  32. else _level0.info_mc.text_txt.text += "No Lat and Lng!\n";
  33. } else {
  34. loadDataLV = null;
  35. sendDataLV = null;
  36. _level0.info_mc.text_txt.text += "Can't connect server to get Lat and Lng!\n";
  37. }
  38. }
  39.  
  40. // start loading map from Google
  41. function loadMap():Void {
  42. // show info
  43. _level0.info_mc.text_txt.text += "Loading map...\n";
  44. _level0.info_mc.text_txt.text += "Latitude: "+loadDataLV.latitude+"\n";
  45. _level0.info_mc.text_txt.text += "Longitude: "+loadDataLV.longitude+"\n";
  46. // map size
  47. var mapWidth = 350;
  48. var mapHeight = 520;
  49. // lat and lng
  50. var lat = loadDataLV.latitude;
  51. var lng = loadDataLV.longitude;
  52. var apiKey = 'API_KEY';
  53. // JPG loader
  54. var loader:MovieClipLoader = new MovieClipLoader();
  55. // url
  56. var mapUrl:String = 'http://maps.google.com/staticmap?center=' +
  57. lat + ',' + lng + '&format=jpg&zoom=15&size=' +
  58. mapWidth + 'x' + mapHeight + '&key=' + apiKey +
  59. "&markers="+lat+","+lng+","+"greena";
  60. // start map load
  61. loader.loadClip(mapUrl, _level0.info_mc.map_mc);
  62. _level0.info_mc.text_txt.text += "Loading, please wait...\n";
  63. }

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.

25 Comments

  • Hi,Pasi

    That’s great,Thanks for your share.

  • […] S60, Source Codes — Li YongFei @ 10:04 pm Pasi has released a new Flash Lite code: Contacts Demo – S60 Platform Services API example with Flash Lite. This is his first S60 Platform Services API test with Flash Lite. This demo application first […]

  • This is great.

    Very interesting and nice. Thanks for sharing.:)

  • […] it here. VN:F [1.1.8_518]Submitting…Rating: 0.0/5 (0 votes cast) « Devnet Article Update: […]

  • cool :)

    Cheers

  • […] published a very interesting Flash Lite example using new S60 Platform Services API: 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 […]

  • […] posted a great Flash Lite demo using the S60 Platform Services API to list the contacts from the phone and then show a Google Map […]

  • Great article Pasi! Thanks for sharing with the community.

  • 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 :)

  • 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

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

  • Christian,

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

    Pasi

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

  • Christian,

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

    Pasi

  • […] Pasi Maninen ha vuelto a ponerse a trastear con Flash Lite, y como siempre el resultado ha sido un recurso de inestimable valor para la comunidad de desarrolladores. Esta vez le ha dado por jugar con la API de Servicios de Nokia disponible desde S60 5th Edition, y ha hecho una aplicación de demostración que se asemeja mucho a lo que preparó un servidor para el pasado Adobe Hispano, y que no pude mostrar como me hubiera gustado ya que Adobe Connect no se llevaba demasiado bien con el Remote Device Access de Nokia XD […]

  • Thank you!

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

  • 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

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

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

  • frustr8ed,

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

    Pasi

  • […] Access it here. […]

  • […] improved my eariler example which loads contact informations from users device – displays informations to scrollable list and […]

  • it is work in flash lite 2.1?

  • bb,

    you will need Flash Lite 3.0 or above.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>