Posted By

EgoAnt on 08/11/11


Tagged

flash game as3 Analytics


Versions (?)

Clicky Analytics Tracking Code for Flash Games


 / Published in: ActionScript 3
 

URL: http://egoant.com/tutorials/10-flash-games/41-getting-clicky-with-flash-game-tracking.html

  1. package com.egoant.clicky
  2. {
  3.  
  4. import flash.external.ExternalInterface;
  5.  
  6. public class ClickyTrack
  7. {
  8.  
  9. private var GameName:String;
  10.  
  11. private const JS_Function:String = "clicky.log";
  12.  
  13. public function ClickyTrack(GameName:String):void
  14. {
  15. this.GameName = "#" + escape(GameName);
  16. }
  17.  
  18. public function LogEvent(EventName:String):void
  19. {
  20. var constructedCall:String = JS_Function + "('" + GameName + "-" + FormatEntry(EventName) + "','" + FormatEntry(EventName) + "')";
  21. ExternalInterface.call("setTimeout", constructedCall, 0);
  22. }
  23.  
  24. private function FormatEntry(InputText:String):String
  25. {
  26.  
  27. var OutputText:String;
  28.  
  29. var myPattern:RegExp = /%20/g;
  30. OutputText = escape(InputText).replace(myPattern, " ");
  31.  
  32. return OutputText;
  33. }
  34.  
  35. }
  36.  
  37. }

Report this snippet  

You need to login to post a comment.