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
You could use this library (or senocular’s) 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.
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.
Super helpful. I just got everything working using senocular’s library.
Thanks once again for talking me off of the ledge.
1 Like