package { import flash.display.Bitmap; import flash.display.BitmapData; [SWF(width=1200, height=600, backgroundColor=0x000000)] /** * Demonstrates how two images can be combines by using BitmapDta's compare() method. */ public class graphic_flex_image_effects_04_Flex_CompareTest extends graphic_flex_image_effects_04_Flex_DualImageTest { /** * Called after two images have been loaded by super class. * This creates a third image using compare() with loaded images. */ override protected function operateOnImages():void { var bitmap0:Bitmap = getChildAt(0) as Bitmap; var bitmap1:Bitmap = getChildAt(1) as Bitmap; var comparedData:Object = bitmap0.bitmapData.compare(bitmap1.bitmapData); // compare() can return either bitmap data or a number if (comparedData is BitmapData) { var bitmap:Bitmap = new Bitmap(comparedData as BitmapData); addChild(bitmap); // place to the right of loaded images bitmap.x = bitmap1.x + bitmap1.width; } } } }