Revision: 11369
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 3, 2009 12:53 by chrisaiv
Initial Code
var mc:MovieClip = new MovieClip(); mc.buttonMode = true; mc.addEventListener( MouseEvent.CLICK, trackEventHandler, false, 0, true ); function isProductionMode():Boolean { var runtimeEvironment:String = Capabilities.playerType; if (runtimeEvironment == "External" || runtimeEvironment == "StandAlone"){ return false; } else { return true; } } function trackEventHandler( e:Event ):void { //If the Complied Flash Player is on the HTML page, give it a Page View if( isProductionMode() ){ navigateToURL(new URLRequest("analytics._trackPageView()"), '_self'); } }
Initial URL
Initial Description
There are many ways to tweak this code but hopefully this will get you all started. Whenever I'm tracking PageViews or Events for something like Google Analytics, I don't want navigateToURL() to interfere while I'm developing. These two functions will keep navigateToURL() from trying to load a Browser page until the SWF is loaded into an HTML page
Initial Title
As3: Track Pageviews only in Production Mode
Initial Tags
Initial Language
ActionScript 3