How to show MSN status in Flex app form?

342 views Asked by At

I have a flex business application and need to create some control that will show a small picture symbol of given user's MSN messenger status (online, away etc.)

Alternatively, how to insert an html page inside flex form?

There is a HTML code snippet on MSN site (supposed to be) doing exactly what I want, here it is:

<a target="_blank" href="http://settings.messenger.live.com/Conversation/[email protected]&mkt=ru-RU">
    <img style="border-style: none;" src="http://messenger.services.live.com/users/[email protected]/presenceimage?mkt=ru-RU" width="16" height="16" />
</a>

(it can be found here: http://settings.messenger.live.com/Applications/CreateHtml.aspx)

Also I'll need to replace eb892994c712bb83 in this snippet with user's cid code. How to find user's cid knowing his/her MSN account name is one more question...

2

There are 2 answers

0
merv On

The HTML support within Flex (outside of AIR) is quite limited.

Another option is to use an Image control:

<s:Image id="msnLiveStatusIcon"
         creationComplete="initStatus()"
         click="openMSNLive()" />

where initStatus and openMSNLive are defined along the following lines:

private var userCID:String = "eb892994c712bb83";

protected function initStatus():void {
  var iconURL:URLRequest = new URLRequest("http://messenger.services.live.com/users/" 
    + userCID + "@apps.messenger.live.com/presenceimage?mkt=ru-RU");

  msnLiveStatusIcon.source = iconURL;

  // poll to check for updated status
  var pollTimer:Timer = new Timer(60000); // once a minute
  pollTimer.addEventListener(TimerEvent.TIMER,
    function (e:TimerEvent):void {
      msnLiveStatusIcon.source = null;
      msnLiveStatusIcon.source = iconURL;
    });

  pollTimer.start();
}

protected function openMSNLive():void {
  navigateToURL(new URLRequest("http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee="
    + userCID + "@apps.messenger.live.com&mkt=ru-RU"),
    "_blank");
}

The polling is optional. The anonymous function for the listener is used for brevity only, and not recommended for production.

0
coder On

Ok, week of investigation and some results:

1) MSN API exists for .NET and JavaScript - getting status from ASP.NET server side is possible;

2) there is an arcane ActiveX control named Name.NameCtrl that comes with Microsoft Office and can be used from JavaScript to retrieve MSN user status;

And
3) simplest way is to use htmlText property on a Flex control, for example on mx:TextArea control. Assigning HTML quoted in the question to htmlText property "just works". Comprehensive guide to htmltext property is here:

html_text_property_help