topical media & game development

talk show tell print

#graphic-flex-image-effects-04-Flex-MergeTest.ax

#graphic-flex-image-effects-04-Flex-MergeTest.ax [swf] [flash] flex


  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 @ax-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;
                  }
  
          }
  
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.