user3101195
user3101195

Reputation: 1

AS3 Flash - Save movieclip as png

I use AS3 flash. Can someone help me? I want that if you press the save_image button, then it saves "guy" movieclip as png. But It's not work:

import com.adobe.images.JPGEncoder;
import com.adobe.images.PNGEncoder

save_image.addEventListener(MouseEvent.CLICK, save_image_function);
function save_image_function(event:MouseEvent):void
{
var bmd:BitmapData = new BitmapData(50,50);
bmd.draw(guy);
var encorder:PNGEncoder   = new PNGEncoder();
var bytes:ByteArray = encorder.encode(bmd);
var file:FileReference    = new FileReference();
file.save( bytes, "Image.png" );
}

Can someone help me? The error code is this:

ReferenceError: Error #1069: Property encode not found on com.adobe.images.PNGEncoder and there is no default value. at pr2sets_fla::MainTimeline/save_image_function()

Upvotes: 0

Views: 1970

Answers (1)

Nambew
Nambew

Reputation: 640

The encode method is static, you need to call it this way.

var bytes:ByteArray = PNGEncoder.encode( bmd );

Upvotes: 3

Related Questions