My friend
Sebastian Recabarren pointed me out a little problem about my Skype Status flash widget. He asked me who was lying or his Skype or my blog.
Browser's cache memory!
I though this problem was only when the user goes online through a proxy server, which keeps everything in its cache, but seems like flash always takes the image from the browsers cache even if there is no proxy server in between.
To avoid this problem, we can use an XML provided by
SkypeWeb instead of loading the image.
The XML is available from:
http://mystatus.skype.com/userID.xml
That data is easy to pull from flash and then show the right status attaching the right movieclip.
What I did is, instead of
image01.loadMovie("http://mystatus.skype.com/smallclassic/yourID");
I'm loading the XML as follows:
function loadXML(loaded:Boolean):Void {
if (loaded) {
xmlNode = this.firstChild;
my_status = xmlNode.childNodes[0].childNodes[2].childNodes;
attachStatus();
} else {
trace("XML not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://mystatus.skype.com/myID.xml");
function attachStatus():Void {
image01.loader_mc.attachMovie(my_status,"status",1)
}
I have added 6 movieclips showing the different possible status, each of them have a linkage identifier name depending on the status. To add an identifier to a movieclip just right click on it (in the library) and select "
linkage properties", tick the "
Export for actionscript" option and change the identifier to its equivalent skype status, ie: Not Available
Voila!
Testing locally everything works fine.
But, as usual when debugging, there is a new problem: cross domain policies.
Due to security reasons, any online flash application cannot load data from a different server and my experiment doesn't work online.
My mate
Stephen Downs (Tink) pointed me out the solution:
It is possible to get round the sandbox by loading the XML into some PHP or something on your server and then loading it into Flash from there. Tricks the player into thinking your serving it
and my colleague
Thomas Van Steenwinckel gave me a hand with the php and together we put the following script on my server:
<?
header("Content-type: text/xml; charset=utf-8");
$filename = "http://mystatus.skype.com/myID.xml" ;
$dataFile = fopen($filename, "r" );
if ( $dataFile )
{
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
fclose($dataFile);
}
else
{
die( "fopen failed for $filename" ) ;
}
?>
Now on flash I'm loading the XML created by this php instead of the one provided by skypeWeb and my blog shows the right status of my Skype account.
Nice way to get rid of the cross domain issues.
PD: Just in case, remember to update to the
latest Skype.
Salut!
-- IMPORTANT UPDATE --
Part IPart IIFree Skype Status Flash Buttonand the latest one of this series:
Easy Skype status in Flash---------