Creating A Custom Support Chat Icon From SmarterTracker

Recently I was tasked to create a notifier that smarterTracker support chat is online from inside flash. I quickly explored Tracker for any setting that would allow me to check on some script that would return either 1 for online and 2 for offline. To my dismay, after almost an hour of looking into the admin area, i found absolutely nothing. Tracker do provide a way to show the online/offline image using javascript and html. I started to dig down their code and checked what scripts where they checking and how are they doing the notifier.

Their trick puzzled me a bit. Its not quite obvious with just one look but with time i figured the secret out. They are returning a transparent gif, which for some odd reason is of the same filesize when it online and offline. They are returning for online a 1 pixel by 1 pixel transparent gif when online and a 1 pixel x 2 pixel image when offline. Since Flash is not my strong points i created a simple php file to check the returned image for its height and return it to flash.

PHP Script contents follow:

$domain = 'domain.com';
$port = 1234;
$config_id = 1;

if(strlen($port))
{
$domain .= ':'.$port;
}

$x = getimagesize("http://".$domain."/ChatScript.ashx?config=".$config_id."&refresh=1&time=".time());
echo $x[1];

And on the flash side of things on the first frame of your movie clip that shows the online and offline image.


stop();

x = setInterval(this, "checkData", 2000);
function checkData()
{
domain = 'domain.com';

var c:XML = new XML();
c.load("http://" + domain + "/status.php");
c.onData = function(data)
{
if(parseInt(data)== 1)
{
//online - modify this to fit your needs
onlinechat.gotoAndStop('online');
}
else
{
//offline - modify this to fit your needs
onlinechat.gotoAndStop('offline');
}

}
}


Leave a Comment

(required)

(required)