Question

I have a complex graphics data on a sprite or a shape (no matter which is exactly). But I want to draw shadow (inner too) for one Rect ( [10, 10, 240, 25] for example) or another path.

  /// code before
  grObj.graphics.drawRect( 10, 10, 240, 25);
      /// -> draw inner shadow on this objcect somehow
  /// code after

Is it possible to perform w\o filters?

ps. http://ipicture.ru/uploads/100927/RHZF1K6Exu.png


solving:

BitmapData(*).applyFilter( *,*,*,*); // play with this function :)

also http://help.adobe.com/ru_RU/AS3LCR/Flash_10.0/flash/display/BitmapData.html#applyFilter()

Was it helpful?

Solution

i'm assuming you don't want to add filters to your object because you plan on adding a colorTransform and do not want the filters to also change color.

if that's the case what you can do is separate the filter by creating another sprite of the same size as the original, add a drop shadow filter to the new sprite with the hideObject parameter set to true.

//display object
var grObj:Sprite = new Sprite();
grObj.graphics.beginFill(0xFF0000, 1);
grObj.graphics.drawRect(0, 0, 240, 25);
grObj.graphics.endFill();

//filter object
var dsFilter:Sprite = new Sprite();
dsFilter.graphics.beginFill(0);
dsFilter.graphics.drawRect(0, 0, grObj.width, grObj.height);
dsFilter.graphics.endFill();

dsFilter.filters = [new DropShadowFilter(4.0, 45, 0, 1.0, 4.0, 4.0, 1.0, 3, true, false, true)];

//display list
grObj.x = dsFilter.x = 10;
grObj.y = dsFilter.y = 10;

addChild(grObj);
addChild(dsFilter);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top