Question

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.

Was it helpful?

Solution

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);
    }
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top