# Detect Actionscript Version of external SWF

**URL:** <https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252>\
**Category:** flash\
**Created:** [May 29, 2015, 6:21pm UTC](https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252 "2015-05-29T18:21:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveNigella](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@DaveNigella](https://forum.kirupa.com/u/DaveNigella)\
**Post date:** [May 29, 2015, 6:21pm UTC](https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252/1 "2015-05-29T18:21:07Z")

</div>

I have a main AS3 file that allows the user to upload and load an external SWF into a containerMC. The external SWF must be AS3 otherwise some of the functionality won’t work correctly.

So after loading, I need to determine the AS version of the external file so I can warn the user that the file is incompatible.

The closest answer I’ve found in Googleland is the trace code below but it outputs “false” no matter which version of AS the external SWF contains.

trace(containerMC.content is AVM1Movie);  
// AS1/2 = true AS3 = false

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [May 29, 2015, 6:51pm UTC](https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252/2 "2015-05-29T18:51:04Z")

</div>

You could use [this library](https://github.com/krilnon/abc-abstraction) (or [senocular’s](http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/SWFReader.as)) to check whether or not there are any DoABC tags in the SWF. AS1/2 used DoAction tags.

Actually it looks like senocular’s exposes the ActionScript version pretty cleanly… it’s just the `asVersion` property on an SWFReader instance. His code hasn’t been updated in a while, though, so it’ll choke on SWFs compressed with LZMA.

If you want to use my library… the fastest way is probably `SWF.readFrom(containerMC.concent.loaderInfo.bytes).abcs.length > 0` if it’s AS3. `== 0` if it’s AS1/2. All DisplayObjects have a `loaderInfo`… so whatever you’ve loaded will have that property.

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [May 29, 2015, 9:59pm UTC](https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252/3 "2015-05-29T21:59:45Z")

</div>

It’s also probably worth noting that `containerMC.content` is probably wrong in general. Like, if `containerMC` is actually a MovieClip, it won’t have a `content` property to begin with. `Loader`s have a `content` property, which would be an AVM1Movie if it was an AS1/2 SWF.

---

<div class="post-metadata">

**Author:** ![DaveNigella](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@DaveNigella](https://forum.kirupa.com/u/DaveNigella)\
**Post date:** [May 29, 2015, 10:24pm UTC](https://forum.kirupa.com/t/detect-actionscript-version-of-external-swf/633252/4 "2015-05-29T22:24:32Z")

</div>

Super helpful. I just got everything working using senocular’s library.

Thanks once again for talking me off of the ledge.
