A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Problems with draw()

Threaded View

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Problems with alpha

    hello, I'm very new to AS3.0 and I have problems with alpha. The next code is from my animation class and its main purpose is draw frame to other bitmapdata object.

    Code:
    // Copy the frame from original BitmapData.
    			destBitmapTempData.copyPixels(bitmapData, rect, zeroPoint);
    			
    			// Set the newly copied BitmapData to Bitmap.
    			modifiedBitmap.bitmapData = destBitmapTempData;
    			
    			// Change alpha
    			modifiedBitmap.alpha = 0.5;
    			
    			// Get Matrix from the modifiedBitmap.
    			matrix = modifiedBitmap.transform.matrix;
    			
    			// Change it if necessary
    			if (flipHor)
    			{
    				matrix.scale( -1, 1);
    				matrix.translate(width, 0);
    			}
    			if (flipVer)
    			{
    				matrix.scale( 1, -1);
    				matrix.translate(0, height);
    			}
    			
    			// Clear previous frame.
    			destBitmapData.fillRect(zeroRect, 0x00000000);
    			
    			// Draw the new frame.
    			destBitmapData.draw(modifiedBitmap, matrix);
    	
    			// Copy the new frame to canvas.
    			canvasBD.copyPixels(destBitmapData, zeroRect, position, null, null, true);
    The thing is that when I use copyPixels, the frame loses its alpha value. For example if I do new bitmap object from destBitmapData and addChild it, then the alpha remains, but not when I use copyPixels

    The canvasBD is created:

    Code:
    canvasBD = new BitmapData(screenRect.width, screenRect.height, true, 0x00FFFFFF);
    Any ideas how do I get alpha remain to that frame?
    Last edited by kadaAS3; 12-01-2008 at 06:16 AM. Reason: wrong topic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center