1

I'm trying to use away3d to load a texture. Everything works fine except when embedding a texture inside the project, it crashes and gives that

error: VerifyError: Error #1014: Class mx.core::BitmapAsset could not be found. 

The code for embedding the texture:

[Embed(source="../embedded/texture.jpg")]
public var reelTexture:Class;  

I'm using Adobe flex builder 3, Away3d 4.1.

andre_lamothe
  • 2,171
  • 2
  • 41
  • 74

1 Answers1

1

The problem is that you don't have framework.swc/core.swc/flex.swc (depending of your Flex SDK version) in your project library path, however linking this swc can lead in increasing the size of your application by ~200kb when compiled with mxmlc, even if you don't use flex directly.

I recommend you do the following (we do this in our pure as3 projects):

1.Create flex library project named flex4embedapi (or flex3embedapi depends on the version of Flex SDK you use in your main project)

2.Create file classes.as:

package
{
    import mx.core.BitmapAsset;
    import mx.core.ByteArrayAsset;
    import mx.core.FontAsset;
    import mx.core.SoundAsset;
    import mx.core.SpriteAsset;

public class classes
{
    public function classes()
    {
        ByteArrayAsset;
        SpriteAsset;
        BitmapAsset;
        FontAsset;
        SoundAsset;
    }
}
}

3.Be sure this class is included in the library including list (Project->Properties->Flex library build path->Classes)

4.Copy flex4embedapi.swc to the lib folder (folder with linked swc libraries) of your project.

All should works now.

UPD: For quick fix try this config file for Flex SDK 4.6 (-load-config=config.xml) it's 100% works for as3 project without any other linked libraries:

<flex-config>
    <target-player>11.1.0</target-player>
    <default-frame-rate>40</default-frame-rate>

    <compiler>
        <locale>
            <locale-element>en_US</locale-element>
        </locale>

        <external-library-path>
            <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}/playerglobal.swc</path-element>
        </external-library-path>

        <library-path>
            <path-element>${flexlib}/libs/core.swc</path-element>
            <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}</path-element>    
        </library-path>

        <optimize>true</optimize>

        <warn-no-constructor>false</warn-no-constructor>
    </compiler>
</flex-config>

Test project contains the only main class embedtest.as:

package
{
import flash.display.Sprite;
import flash.utils.ByteArray;

public class embedtest extends Sprite
{
    [Embed(source="somefile.txt", mimeType="application/octet-stream")]
    private static const some_file:Class;

    public function embedtest()
    {
        var b:ByteArray = new some_file();
        trace(b.length);
    }
}
}
fsbmain
  • 5,267
  • 2
  • 16
  • 23
  • I added the framework.swc for a quick fix, the problem is the same. Furthermore, When adding also the target player to be 11.1, I get the following warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option. – andre_lamothe Sep 25 '13 at 09:34
  • Quick fix depends of the version of SDK that you use, for example for SDK 4.6 you should add _core.swc_ instead of _frameworks.swc_, for the 3.6 it a _flex.swc_ – fsbmain Sep 25 '13 at 09:45
  • For 4.6, core.swc is there, I even removed it and added it again, the problem is the same :(. Really weird. – andre_lamothe Sep 25 '13 at 10:06
  • 1
    try approach with config in my updated answer in a simple demo project, hope it helps – fsbmain Sep 25 '13 at 10:18
  • Thanks for following up. Where should I put the new config.xml ? how do I create it? should I also put -load-config in the compilers options ? – andre_lamothe Sep 25 '13 at 11:11
  • I recommend you first create new pure as3 test project for testing, create new _config.xml_ file with the content from my answer in any editor or in flash builder and put it in the project main source folder (usually /src). I recommend you to remove all compiler options and all linked libraries (including Flex 4.6 SDK) and add single options _-load-config_. As test project will works fine it will be more easy to make works your main project. – fsbmain Sep 25 '13 at 11:16
  • The definition of base class BitmapAsset was not found and also for the Sprite. For the following config file... – andre_lamothe Sep 25 '13 at 11:25
  • Normally, this approach is IDE independent, for example I use it in IDE for debugging (Flash Builder 4.6), but production build makes by ant, but it's hard to figure out your problem in Flash Builder 3 remotely. – fsbmain Sep 25 '13 at 12:14