package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.geom.Point; [SWF(width=1200, height=600, backgroundColor=0x000000)] /** * Demonstrates how two images can be combines by using BitmapDta's merge() method. */ public class graphic_flex_image_effects_04_Flex_MergeTest extends graphic_flex_image_effects_04_Flex_DualImageTest { /** * Called after two images have been loaded by super class. * This creates a third image using merge() with loaded images. */ override protected function operateOnImages():void { var bitmap0:Bitmap = getChildAt(0) as Bitmap; var bitmap1:Bitmap = getChildAt(1) as Bitmap; var mergedData:BitmapData = new BitmapData(bitmap0.width, bitmap0.height); // first, draw in first image mergedData.draw(bitmap0); // second, merge data from second image mergedData.merge(bitmap1.bitmapData, mergedData.rect, new Point(), 0, 0xFF, 0x7F, 0); var bitmap:Bitmap = new Bitmap(mergedData); addChild(bitmap); // place to the right of loaded images bitmap.x = bitmap1.x + bitmap1.width; } } }