views:

329

answers:

3

In as3 I'm creating a drop shadow, which works fine. But when I change the height or width of the object (mcWhiteBorder) the drop shadow does not appear at all. Any ideas?

var mcWhiteBorder:whiteBorder = new whiteBorder();
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.distance = 1;
dropShadow.alpha = .2;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
mcWhiteBorder.height = houseXML.height-40;
mcWhiteBorder.width = houseXML.width+5;
mcWhiteBorder.x = houseXML.photoX-10;
mcWhiteBorder.y = houseXML.photoY+20;
mcWhiteBorder.filters = [dropShadow];

addChild(mcWhiteBorder);

Thanks in advance!

A: 

I'm not seeing any problems syntax-wise.

dropShadow.distance = 1;
dropShadow.alpha = .2;
dropShadow.blurX = 10;
dropShadow.blurY = 10;

That's pretty faded out. Change alpha to 1 or 2 and see if you can see it. Also, you don't seem to be setting the color. I think the default is black. Make sure you're object isn't over something dark and you're just missing it.

McAden
Well the thing is, I do see it. As long as I don't change the height or width, so I think its more than just the alpha.
Matt
A: 

I've copied and pasted your code and it seems to work. Sure, I don't know what your library symbol looks like (i just used a gray sqare) and I've replaced the houseXML variable with static values. The code I've tried is the following:

var mcWhiteBorder:whiteBorder = new whiteBorder();
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.distance = 1;
dropShadow.alpha = .2;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
mcWhiteBorder.height = 200;
mcWhiteBorder.width = 300;
mcWhiteBorder.x = 50;
mcWhiteBorder.y = 50;
mcWhiteBorder.filters = [dropShadow];

addChild(mcWhiteBorder);

It seems to work just fine.. Check your houseXML and see if the values you assign are valid and so on.

I've had some problems in the past with this, also. I've come to the conclusion that it always works if you're adding the filter to the existing filter array, instead of creating a new one, even if it's empty. I'm not really sure why. Your code would be something like:

var mcWhiteBorder:whiteBorder = new whiteBorder();
var tmpFilters:Array = mcWhiteBorder.filters;
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.distance = 1;
dropShadow.alpha = .2;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
mcWhiteBorder.height = houseXML.height-40;
mcWhiteBorder.width = houseXML.width+5;
mcWhiteBorder.x = houseXML.photoX-10;
mcWhiteBorder.y = houseXML.photoY+20;
tmpFilters.push(dropShadow);
mcWhiteBorder.filters = tmpFilters;

addChild(mcWhiteBorder);

So instead of asigning a filter to the filters property, you're actually adding that filter to the existing ones. I'm curious if that works.

evilpenguin
I've never had any problems assigning filters that way... you should always be aware that DisplayObject.filters is an array and behaves that way... if you assign a new array of filters to a clip with filters on it, it will obviously replace all previous filters...
Cay
A: 

Take note that filters don't work with clips bigger than "certain values", have a look at the comments in this thread...

Cay