PDA

View Full Version : copyPixels while moving bitmap when overlay layer has bitmap effects bug?



ez74
September 13th, 2008, 12:19 PM
hi,

Wanted to create a walking character, using a large image of all this character postures as resource.

Did this:
1. Created a new Bitmap with its BitmapData
2. Created an EnterFrame event listener to this Bitmap where:
a. I move the Bitmap to the right
b. I change the character posture by copying pixels from the large image to the characters BitmapData

Works fine...

But then I've added another layer (sprite) on top of this bitmap.
Added a glow filter to this layer (sprite) and got the following bug:
The character (Bitmap) is leaving trails as it moves... as if Flash doesn't clean after it...

Please see attached files - it's all there, short and clear.

Basically, the pseudo code looks like this:
--------------------------------------------------------------------------------------------------------------
var __sourceBmpData:SourceBmpData = new SourceBmpData(72, 128); // SourceBmpData is a linkage name to an image on the library
var __imgBmpData:BitmapData = new BitmapData(24, 32, true, 0x00000000);

var __imgBmp:Bitmap = new Bitmap(__imgBmpData);
this.addChild(__imgBmp);

// add event listener
__imgBmp.addEventListener(Event.ENTER_FRAME, Walk);

// bug layer
var bug_mc:Sprite = new Sprite();
this.addChild(bug_mc);

var glow:GlowFilter = new GlowFilter();
glow.color = 0xFF0000;
bug_mc.filters = [glow];

// enter frame
private function Walk(event:Event):void {
__imgBmp.x = 32 + __posX * 12;
__imgBmpData.copyPixels(__sourceBmpData, new Rectangle((__posX % 3) * 24, 32, 24, 32), new Point(0, 0));

__posX++;
}

--------------------------------------------------------------------------------------------------------------

Is it a bug or am I doing somthing wrong?

Thanks,
EZ

sekasi
September 14th, 2008, 06:55 PM
The filter is applied to the sprite, not to the contents. If you wanna do this you need to attach the filter to the bitmapdata with bmd.applyFilter();

ez74
September 17th, 2008, 12:52 PM
Actually my intention was to apply this filter to a layer above the bitmap...

Anyway, I've found out that its working fine under a newer version of the player - 9,0,115,0.
So seems like this bug is solved...

Thanks