Colour Tween and BitmapData


(Adam Edney) #1

Hi All,

I’m making a UI interface and I’m adding a colour tween to my button class. I’m using a Stamp as the graphic, but I hit a problem.

Inorder to change the Stamps colour I need to recreate the bitmapdata, which is not the more effective way of doing it. e.g.

  if (colourTween.active)
      updateColourTween();

  private function updateColourTween():void
  {
   graph.clear();
		
    graph.beginFill(colourTween.color, 1);
    graph.drawRoundRect(borderWidth, borderWidth, width, height, roundness);
				
    if (filters != null)
	sprite.filters = filters;
					
    bd = new BitmapData(width + (borderWidth * 2), height + (borderWidth * 2), true, 0);
    bd.draw(sprite);
		
    stamps[_status - 1].source = bd;
   }

Is there a better way of doing this with a Stamp?

Cheers, Adam


(Zachary Lewis) #2

Nope. Stamp is great for graphics that aren’t modified and used “as is.” Just use an Image and you’ll have a lot better luck with manipulating your graphics.


(Adam Edney) #3

Cheers, I through that will be the answer.