;

PDA

Click to See Complete Forum and Search --> : Remotely detecting swf version


Obidos
11-23-2008, 02:04 PM
Is it possible to remotely detect the version of an swf file with some actionscript code? For instance, you type the url of an swf file, and it shows you the version.

like:

http://xamplesite.com/test.swf

and it says

swf version x.x.x.x
or whatever.

cancerinform
11-23-2008, 04:05 PM
You can detect if it is a AMV1 (AS1 or AS2) movie or not by checking the
event.currentTarget.content
of a loaded swf.

Obidos
11-24-2008, 12:39 PM
what about as3?

cancerinform
11-24-2008, 12:56 PM
Sure, you will get AMV2 as output.

Obidos
11-24-2008, 01:00 PM
Ok, thanks. What do I do, load it into a movie clip, run that on the movie clip to equal a variable, and output the variable to a text box or something?
Like:

loadbtn.onRelease() {
var output;
loadMovie(movietoload.text, loadermc);
event.loadermc.content = output;
outputbox.text = output;
}

cancerinform
11-24-2008, 01:19 PM
Are you using AS2? Then it would not work. You need to use AS3.

Obidos
11-24-2008, 01:40 PM
whoops, my mind is in as2 mode. How bout this:

stop();

loadbtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {

var request:URLRequest = new URLRequest(movietoload.text);
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
loadermc.addChild(loader);

event.currentTarget.content = outputtext.text;
};

This works brilliantly, except it doesn't output anything into outputtext.text

Obidos
11-24-2008, 05:49 PM
Is there a way to output the result of the event.currentTarget.content?
I don't really understand how to use it :confused:

cancerinform
11-25-2008, 11:48 AM
You need to add an eventlistener.

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler);
function completeHandler(event:Event):void
{
outputtext.text=event.currentTarget.content;
}

Obidos
11-26-2008, 12:58 PM
In

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler);

CO MPLETE is actually COMPLETE right? Yeah I think it is.

Just tested it, works perfectly for AS1 and AS2, but for AS3, it just loads the movie and nothing outputs to the text. ASMV1 or whatever comes for AS2 and 1, but for AS3, nothing. But the movie loads though. Any problems here? This is the code I'm using:

stop();

loadbtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {

var request:URLRequest = new URLRequest(movietoload.text);
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
loadermc.addChild(loader);

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler);
function completeHandler(event:Event):void {
outputtext.text=event.currentTarget.content;
}
};