开发者

how to embed pure as3 bitmap assets with flex4 (worked with flex3)

In Flex3, I could compile pure as3 code and use "embed" tags to load in images. This was done by Flex making a BitmapAsset class.

I can still do this in Flex4.

However, there was a trick to fakeout flex3 and use my own mx.core.BitmapAsset class to remove some of the extraneous stuff Flex's BitmapAsset brings in with it. This is described here: http://www.ultrashock.com/forums/flex/embed-flex-assets-without-using-flex-123405.html

Unfortunately, I cannot get these tricks to work with Flex4 and get smaller file sizes. I end up with the error "VerifyError: Error #1014: Class mx.core::BitmapAsset could not b开发者_C百科e found."

This error leads me to this forum, and a solution as described there: http://tech.groups.yahoo.com/group/flexcoders/message/148762

Following this advice, I add -static-link-runtime-shared-libraries=true, and my swf loads without an error... but this means I am loading in the pieces of the flex framework I wanted to omit (and the file size says so too).

Is there a better way to fake out flex4 when it comes to using Embed?


Will something like work ?

[Embed(source="yourImage.jpg")]
private var ImageC:Class;
private var image = new ImageC();

Keith Peters has a nice article on the subject.


I've created a test project in Flex 4 with [Embed] and fake BitmapAsset.as and can't see the exception:

package
{
import flash.display.Sprite;
public class EmbedTest extends Sprite
{
    public function EmbedTest()
    {
        addChild(new smile());
    }

    [Embed("smile.png")]
    private var smile:Class;
}
}

Try to add -link-report link-report.xml compiler option and check link-report.xml file in bin-debug.

Do you have BitmapAsset.as there? If no, you may have excluded it by externs, external-library-path or load-externs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜