[SWF (width = 550, height = 400)] //the dimensions should be same as the loaded swf's
public class Main extends Sprite
{
[Embed (source = "xyz.swf", mimeType = "application/octet-stream")]
// source = path to the swf you want to protect
private var content:Class;
private var context : LoaderContext = new LoaderContext(false, new ApplicationDomain());
public function Main():void
{
var loader:Loader = new Loader();
loader.loadBytes(new content(), context);
addChild(loader);
}
}
}
and it results always in the following error.
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Main$iinit()[D:\shim\Main.as:20]
remains uninitialized. All examples of code that I have encountered have used the Class variable like that. Some of them choose it to use a const instead of a var. I don’t think that matters. What matters is that it probably has a null value.
I guess the Embed is getting messed up. I can’t remember what support CS3 has for it (though I would expect an error if it wasn’t supported)… Or maybe the comment is possibly getting in the way? Are you sure the source path is right?
yeah those annotations ([SWF…] and [Embed…]) are generally used outside of the Flash authoring tool and used with the flex/standalone compiler. If I remember correctly, at some point Flash authoring supported some of those but I’m not sure when and to what extent. [SWF…] I’d imagine would get ignored in favor of the publish settings in Flash, but [Embed…] might work. Then again, maybe not, and I’m not remembering things correctly. You might be able to go through the docs to find out, but again, it might have happened after CS3, so if you find support exists, see if you can link that to a version too.
So I went and downloaded your very own tutorial on flex command line here and did the needful. (The make file was extremely helpful) I compiled the code using the command line flex compiler mxmlc.exe but to my dismay, the errors remain. However I am getting 3 different errors, the first being
VerifyError: Error #1014: Class mx.core::ByteArrayAsset could not be found.
I had thought that the [embed ( … )] tag would have provided the data !??
The other two are i think a consequence if the 1st and are
ReferenceError: Error #1065: Variable Main_content is not defined.
ReferenceError: Error #1065: Variable Main is not defined.
From the example and many others that I looked for on the net, it would seem that
new content() in the line -------> loader.loadBytes(new content(), context);