Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-28-2009, 03:38 AM   #1
snowboardfoo
Registered User
Location San Diego, CA

Posts 17
Afrostyle How to make filters scale relatively with parent DisplayObject ??

AS3 Question for .filters

(i'm using flashdevelop / flex sdk)

IS there any way filters applied to a DisplayObject (drop shadow, glow, bevel) can scale relatively with the parent (the DisplayObject it is inside)?

And what about other properties like .distance for drop shadow?

For example...

If I have a 100px rectangle with a 10px glow inside a container object, and I set scaleX/scaleY of the container to .1, I want the glow to inherit the scale change from the parent (1/10th the size) just as the display object does that the filter is applied to.

Instead, if you try this, you will see the glow stays at 10px no matter what scale the filter target or the container is transformed by.

Pseudocode example (steps to reproduce),

1) create a sprite called _myOuterSprite on stage at scaleX = scaleY = 1

2) create a sprite called _myInnerSprite inside _myOuterSprite at scaleX = scaleY = 1

3) draw 100px rectangle into _myInnerSprite

4) apply 10px glow to _myInnerSprite

5) transform scale of _myOuterSprite to .1

Result:

- child sprite (rectangle) scales to 1/10th the size
- glow stays the same size

How can I make it so that glow scales to 1/10th as well?



...without capturing and scaling bitmap data
...without losing interactivity on objects
...in a way that would work visually for every filter, not just glow (drop shadow has distance property too, etc)
snowboardfoo is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-28-2009, 03:42 AM   #2
snowboardfoo
Registered User
Location San Diego, CA

Posts 17
i tried extending GlowFilter class but i get error:

Error: Base class is final.
snowboardfoo is offline   Reply With Quote
Old 11-28-2009, 07:28 PM   #3
snowboardfoo
Registered User
Location San Diego, CA

Posts 17
Afrostyle anyone?

anyone have any tips?
snowboardfoo is offline   Reply With Quote
Old 11-29-2009, 05:14 AM   #4
wvxvw
Holosuite User
Scale the container of the object you applied the filter to?
Performance-wise filters scale good if set to, for example, for BlurFilter: 2, 4, 8 pixels blurriness. I.e. they use ConvolutionFilter mechanism when calculating the effect, which means they have a pixel matrix, like:
000
0X0
000
or
00000
00000
00X00
00000
00000
etc.

Where X is the pixel we calculate the effect for and 0's are the affected pixels. But if you set it to a value that doesn't translate into whole pixels, the calculation became at least twice more processor intensive.

__________________

I support FlashDevelop (the .NET open source editor for Flash and web developers)
couchsurfing if you need it
wvxvw is online now   Reply With Quote
Old 11-29-2009, 06:37 PM   #5
snowboardfoo
Registered User
Location San Diego, CA

Posts 17
Afrostyle

Quote:
Originally Posted by wvxvw View Post
Scale the container of the object you applied the filter to?
That is exactly the problem- scaling the parent container of a child display object does scale the child display object (thru inheritance of matrix transforms as I understand it) but this does NOT effect the child display object's filters.

Not all properties should scale, either (some should scale, like blurX blurY, and some shouldn't, like color, strength, etc)

I've worked it out to calculate all parent scales and offset filter properties proportionally, but it seems to over compensate... I've settled on offsetting scale/2 and at least visually seems to give the desired effect...

Thanks for the tip on performance, it's a good point. I will round scale-changed properties to whole numbers... I did notice filter rendering starting to slow things down. Gracias!

Same topic on actionscript.org with a bit more content.. http://www.actionscript.org/forums/s....php3?p=946330
snowboardfoo is offline   Reply With Quote
Reply

Tags
actionscript, as3, filters, scale


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:53 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com