Skip to content

Instantly share code, notes, and snippets.

@MatthewCallis
Last active December 16, 2015 06:28
Show Gist options
  • Save MatthewCallis/5391704 to your computer and use it in GitHub Desktop.
Save MatthewCallis/5391704 to your computer and use it in GitHub Desktop.
Detect and record the actual version of Adobe Flash of a visitor.
package com.hark
{
import flash.system.*;
import flash.display.MovieClip;
import flash.external.ExternalInterface;
import flash.events.Event;
import flash.events.SecurityErrorEvent;
public class bs extends MovieClip {
// Allow insecure access so anyone can embed it.
Security.allowInsecureDomain("*");
Security.allowDomain("*");
// Allow JavaScript interaction
if(ExternalInterface.available){
try{
ExternalInterface.call("trackFlash", Capabilities.version);
}
catch(error:SecurityError){
// "User_Changed_AllowScriptAccess"
}
catch(error:Error){
// "User_Changed_AllowScriptAccess"
}
}
}
}
<object width="1" height="1" id="flash-version">
<param name="movie" value="/swfs/bs.swf"/>
<param name="allowscriptaccess" value="always"/>
<param name="allowNetworking" value="all"/>
<param name="wmode" value="transparent"/>
<embed src="/swfs/bs.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowNetworking="all" width="1" height="1" wmode="transparent" name="flash-version"></embed>
</object>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<%= CONFIG.google_analytics_id %>']);
_gaq.push(['_trackPageview']);
(function(){
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
function trackFlash(version){
_gaq.push(['_trackEvent', 'Flash Version', version, 'Domain']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment