Sunday, November 10, 2013

mx.core.BitmapAsset and as3Commons.byteCode

I couldn't get:
var classBuilder:IClassBuilder = packageBuilder.defineClass( _currentClassName, "mx.core.BitmapAsset");

To work.
It kept throwing:
VerifyError: Error #1014

I tried the following solution on stack overflow:
Modify flex-config to say:
< static-link-runtime-shared-libraries > true </static-link-runtime-shared-libraries >
In flash Develop the equivalent is in your config options for the compiler:
See picture below:
That didn't work...
So I found the .swc that the mx.core.BitmapAsset lived in and added it to my project.
Because I know that the "import" statement does NOT work with .swc files in flash develop.
See picture below.
That didn't work...

Then I read this blog post:
http://www.actionscripterrors.com/?p=49
Quote:"Try [...] or adding an instance of the class to the project."

So, to get:
var classBuilder:IClassBuilder = packageBuilder.defineClass( _currentClassName, "mx.core.BitmapAsset");
to work...

I just had to change it to this.
var mxCoreHack:BitmapAsset = new BitmapAsset(null);
var classBuilder:IClassBuilder = packageBuilder.defineClass( _currentClassName, "mx.core.BitmapAsset");
See Pic:


Whooo!!!
Now I am a bit closer to allowing Matt to load assets into the game at runtime.
Wouldn't be so hard if I wasn't configuring the game to be able to switch back and forth
between embedded compile time assets and runtime assets.

No comments:

Post a Comment