How to share the image in the application as3

169 Views Asked by At

I am using the Android-Sharing-Extension-ANE.

How to share an image as result from my application code?

This code does not work

var bitmap:Bitmap = ...;

// encoding image by native encoder (availible on FP 11.3/AIR 3.3 or newer)
var bitmapBytes:ByteArray = bitmap.bitmapData.encode(new Rectangle(0, 0, bitmap.width, bitmap.height), new JPEGEncoderOptions(70)));

var file:File = File.documentsDirectory.resolvePath("image_for_share.jpg");

var stream:FileStream = new FileStream(); // write file to local memory
stream.open(file, FileMode.WRITE);
stream.writeBytes(fileBytes);
stream.close();

SharingExtension.shareImage(file, "Choser title", "Message"));

1

There are 1 best solutions below

2
VC.One On

"How do I share an image with this ANE I use Animate CC?"

From the "Read Me" of that ANE:

How to use:

  • Connect com.illuzor.extensions.SharingExtension.ane file to your Android AIR project.
  • Import com.illuzor.sharingextension.SharingExtension;

Since it's not clear what your exact problem is (because not enough information given)...

(1) Did you import the required Class files?

import com.illuzor.sharingextension.SharingExtension; 


btn_Share.addEventListener (MouseEvent.CLICK, shareAndroid); 


function shareAndroid (event: MouseEvent): void 
{
    //# If this works then replace with bitmap code (use shareImage)
    SharingExtension.shareText ("AS3 Test", "This text is from AS3 code"); 

}

(2) Did you add (connect) the ANE to your project (in Settings)?

Read this for advise on adding an ANE:
https://www.adobe.com/devnet/air/articles/using-ane-in-flash.html