something like this:1) - draw Map to BitmapData (screenshot)2) - change BitmapData as you want (insert logo)3) - as a result save it or ... send to html via ExternalInterface /**
* Embed the logo image.
* Used when saving map as image
* */
[Embed(source="assets/images/logo.png")]
public var logo:Class;
private var pngFileName:String = "image.png";
private var bitmapData:BitmapData;
private var logoBitmapData:BitmapData;
/**
* export png
*/
private function exportPngImage():void
{
if (flashMap)
{
var fileReference:FileReference = new FileReference();
if (flashMap.zoomSliderVisible)
{
// hide zoom slider
/* here if it's necessary also hide:
crosshair at the center of the map,
ESRI logo,
pan arrows around the edge of the map,
scale bar on the map.
*/
hideNavigator();
// add listeners to show zoom slider after execution
fileReference.addEventListener(Event.COMPLETE, fileSaveComplete);
fileReference.addEventListener(Event.CANCEL, fileSaveCancel);
// force UIComponent update/redraw
flashMap.validateNow();
}
try
{
var mapComponent:UIComponent = flashMap as UIComponent;
var exportData:BitmapData = getBitmapData(mapComponent);
if (exportData)
{
// encode to PNG format
var pngEncoder:PNGEncoder = new PNGEncoder();
var byteArray:ByteArray = pngEncoder.encode(exportData);
// exit full screen to show save dialog
this.fullScreen = false;
// open dialog box
fileReference.save(byteArray, pngFileName);
exportData = null;
bitmapData = null;
logoBitmapData = null;
}
}
catch (ioError:IllegalOperationError)
{ // handle error }
catch (error:Error)
{ // handle error }
}
}
/**
* file upload/download canceled by user
*/
protected function fileSaveCancel(event:Event):void
{
showNavigator();
}
/**
* file upload/download completed
*/
protected function fileSaveComplete(event:Event):void
{
showNavigator();
}
/**
* get bitmap data from IBitmapDrawable component
*/
private function getBitmapData(uiComponent:UIComponent):BitmapData
{
if (uiComponent)
{
try
{
// map image size
var mapWidth:Number = uiComponent.width;
var mapHeigth:Number = uiComponent.height;
// get flash map bitmap data
bitmapData = new BitmapData(mapWidth, mapHeigth);
var matrix:Matrix = new Matrix();
bitmapData.draw(uiComponent, matrix);
var logoBitmap:Bitmap = new logo();
// logo image size
var logoWidth:Number = logoBitmap.width;
var logoHeigth:Number = logoBitmap.height;
// get logo bitmap data
logoBitmapData = new BitmapData(logoWidth, logoHeigth);
logoBitmapData.draw(logoBitmap, matrix);
// calculate logo left-top position on map
var logoX:Number = mapWidth - logoWidth - 10;
var logoY:Number = mapHeigth - logoHeigth - 10;
var point:Point = new Point(logoX, logoY);
var mult:uint = 0x100; // 100% (256) RGBA channels multipliers
bitmapData.merge(logoBitmapData, logoBitmapData.rect, point, mult, mult, mult, mult);
}
catch (error:Error)
{
Logger.logError(error);
}
}
return bitmapData;
}