valter
valter

Reputation: 428

How to convert loaded SWF to bitmapdata?

I use the loader class to load some png files to the stage. The function that is called after the file is loaded is something similar to this:

private function IconLoaded(e:Event):void
        {

    percentLoaded_txt.visible = false;
    iconLoader = Loader(e.target.loader);

    icone = Bitmap(iconLoader.content);
    icone.smoothing = true;

    var _icon: imgBox;
    _icon = new imgBox(_MAX_WIDTH, _MAX_HEIGHT, icone,0);//  new imgHelper(_bitmap);

    _icon.x = _main.cena.width/2;
    _icon.y = _main.cena.height/2;
        addChild(_icon);
}

imgBox is a class that auto resize the bitmap and allow also to add border for example...


My code works fine, to load PNG files. But I want also to be able to load swf files.

How can I do this?

Thanks.

Upvotes: 0

Views: 1551

Answers (2)

Q''
Q''

Reputation: 84

You will need to make a copy of the loaded SWF into a Bitmap.

    function copyIt(obj:DisplayObject):Bitmap {
        var bd:BitmapData = new BitmapData( obj.width, obj.height );
        bd.draw(obj);
        return new Bitmap(bd);
    }


    var bmpCopy:Bitmap = copyIt(mySWF);
    addChild(bmpCopy);

Upvotes: 2

Ian Medeiros
Ian Medeiros

Reputation: 1776

You can't load a swf as a bitmap data because they are totally distinct types. What you can do is load a swf and add it as a child of a movie clip to show its content. This link shows how to load a swf. After loading it, you just need to add this as a child of a MovieClip and add this movieclip to the stage to show its content.

Upvotes: 2

Related Questions