views:

315

answers:

2

I have an application that requires resizing of a component that will be scaled up and down quite frequently. I noticed that when I scale the component, any filter I use on it will not scale with it. I realize this makes sense, but I was wondering if Flex had a tool built in that would allow me to scale the filter with the component. I know I can write some actionscript on a custom component and change the scale of the filter properties based off of the component's current scale... Any suggestions?

A: 

if you define the filters in mxml they should scale automatically.

<mx:Canvas width="300" height="300">
  <mx:filters>
    <mx:DropShadowFilter />
  </mx:filters>
</mx:Canvas>

That should produce a canvas that has a basic drop shadow regardless of its size. heres a link to the docs on the various filters: http://livedocs.adobe.com/flex/3/langref/flash/filters/package-detail.html

greg
I tried that before and it didn't work. However, you're link did help a little bit. It made me realize that if I wanted to implement a scaling function based off the scale of my canvas that I'll need to do it the way I was trying to avoid (data-binding in a custom dropShadow class). I grabbed a quote from the livedocs: "This filter supports Stage scaling. However, it does not support general scaling, rotation, and skewing. If the object itself is scaled (if scaleX and scaleY are set to a value other than 1.0), the filter is not scaled. It is scaled only when the user zooms in on the Stage."
Adrian
A: 

My suggestion would be to work with a resizing (allowScale=true, maintaintAspectRatio=false) <mx:Image> PNG 24 with the shadow in it.

You will save CPU and have much better control on it (you're only adding 5-10KB tops).

The dropshadowfilter class was definitely never designed to be animated.

Hope this helps.

keyle