Flash Ad - ActionScript 3 detection?

Published by: Richard Yoon , Outsourced Ad Ops, LLC
Published on: August 26, 2010

What is the best way to know if a Flash ad is coded with ActionScript 3.0? Looking for free sofware options if possible.

I've looked at this tool but it doesn't look like it gives info on the ActionScript Version

http://test.adform.com/Default.aspx

Comments

You can create such a detector using a bit of actionscript.

Below is a link to a very stripped down flash generator I built some time back for my group. I've removed the upload to check functionality for security reasons but just type in a url to a swf and click the arrow. The swf version, as version, frame rate, and dimensions will pull in at the bottom of the widget.

http://shawnfarrington.com/projects/adops/as-version-checker/

A few notes. AS1 files will read as AS2. This can detect all types of flash files however to keep it up to date it should always be republished when a new version of Flash is released.

Below is the AS3 code to make this work if you're interested.

var _loader:Loader;
var _loaderInfo:LoaderInfo;
var _verbose:Boolean = false;
var swfAsVer:Number, swfRate:Number, swfWidth:Number, swfHeight:Number, swfVer:Number;

function LoadDisplayObject(path:String, verbose:Boolean){
_verbose = verbose;
_loader = new Loader();
_loaderInfo = _loader.contentLoaderInfo;
_loaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
_loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
_loaderInfo.addEventListener(Event.INIT, onInit, false, 0, true);
_loaderInfo.addEventListener(Event.UNLOAD, onUnloadContent, false, 0, true);
try{
_loader.load(new URLRequest(path));
}catch (err:Error) {
trace("Unable to load content:\n" + err.message);
}
}

function onComplete(evt:Event):void{
_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
_loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
}

function onIOError(evt:IOErrorEvent):void{
if (_verbose){
trace("A loading error occurred:\n", evt.text);
swfInfo_txt.htmlText = "Uploaded file isn't a valid SWF";
}
}

function onInit(evt:Event):void{
_loaderInfo.removeEventListener(Event.INIT, onInit);
if(_verbose){
if(evt.target.contentType == "application/x-shockwave-flash"){
swfAsVer = evt.target.actionScriptVersion;
swfRate = evt.target.frameRate;
swfWidth = evt.target.width;
swfHeight = evt.target.height;
swfVer = evt.target.swfVersion;
swfInfo_txt.htmlText = "Version:" + evt.target.swfVersion + " AS" + evt.target.actionScriptVersion + "FPS:" + evt.target.frameRate + "Dimensions:" + evt.target.width + " x " + evt.target.height;
}
}
}

function onUnloadContent(evt:Event):void{
_loaderInfo.removeEventListener(Event.UNLOAD, onUnloadContent);
if(_verbose){
trace("unLoadHandler:\n", evt);
}
}

function makeTxtFld(txtFld, cx, cy, w, h, vis, txt):void{
txtFld.x = cx;
txtFld.y = cy;
txtFld.width = w;
txtFld.height = h;
txtFld.textColor = 0xFFFFFF;
txtFld.multiline = false;
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.htmlText = txt;
txtFld.visible = vis;
addChild(txtFld);
}

var swfInfo_txt:TextField = new TextField();
makeTxtFld(swfInfo_txt, 40, 228, 600, 22, true, "");

next_btn.addEventListener(MouseEvent.MOUSE_UP, onNext, false, 0, true);

function onNext(evt:MouseEvent):void{
LoadDisplayObject(swfPath_txt.text, true);
}

Try this... I haven't yet, but it looks promising.
http://forums.adobe.com/message/2056971

Rocket Fuel