0

The bitmap resource, It's usually make the bitmap generate the SWF file ,and use Loader class to load into the application. I search some answers from google, find two ways to generate SWF File, one. use mxmlc tool. and another, use jsfl. I know we can embed the bitmap or swf file into As code. and use mxmlc command like this: the as file is Vip.as , and the code :

package 
{
    public class Vip
    {
        [Embed(source="vip.gif"]
        public static var vip:Class;
    }
}

and now, I use mxmlc Vip.as ... It's has Vip.swf file, upload the Vip.swf file to Server. Then, In flashBuilder, create a new ActionScript project, the application code is :

public class LoadUI extends Sprite
{
    public function LoadUI()
    {
        init(); 
    }

    private function init():void {
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
        var context:LoaderContext = new LoaderContext();
        context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

        loader.load( new URLRequest('http://localhost/swfResouce/Vip.swf'));


    }

    private function completeHandler(e:Event):void {
        var loaderInfo:LoaderInfo = e.currentTarget as LoaderInfo;

    }

and debug the application, Error is:

VerifyError: Error #1014: Class Not Found  mx.core::BitmapAsset.

I don't know how to use mxmlc generate swf file . And no error when debug the code.

Another way is that use JSFL to generate SWF in flash cs5, But I don't know how to use this. Ah, very pain.

grapefrukt
  • 27,016
  • 6
  • 49
  • 73
Lee
  • 97
  • 2
  • 13

3 Answers3

0

I am guessing you want to display an embedded image (gif).

Here is how its done:

package
{
    import flash.display.Bitmap;
    import flash.display.Sprite;

    public class Main extends Sprite
    {

        [Embed(source="vip.gif")]
        private var embeddedVip : Class;


        public function Main()
        {
            var vip : Bitmap = new embeddedVip();
            addChild(vip);
        }
    }
}
Mattias
  • 3,907
  • 4
  • 28
  • 50
0

To avoid

VerifyError: Error #1014

try to compile with static linking:

mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.swf --Main.as

[EDIT]

mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.as
surlac
  • 2,961
  • 2
  • 22
  • 31
0

Why don't you just load the images directly (from Loader) and wrap them in a Sprite? A GIF doesn't exactly need a timeline. :)

pestilence669
  • 5,698
  • 1
  • 23
  • 35
  • I think, e.g. I have a flash game, the bitmap resource are packaged in some SWF files. There is no need to load one by one. It's my idea. If you have good idea, can you tell me? Happy to accept your ideas. – Lee Jun 18 '11 at 04:47
  • Ah. Just take the reference to the BitmapData from the symbol and wrap it in a new Bitmap & Sprite, if not blitting. – pestilence669 Jul 25 '11 at 07:35