Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
sonicworks

Tranformer + Crop .. using AutoFitArea?

Recommended Posts

Hi,

 

I'm just at the thinking stage of developing a tool that as well as transforming can also crop an image. A neat way of doing this (visually) maybe to use the transformer box and handles but maybe changing their behaviour with a 'crop' switch, turning the transformer box and handles red. Then the handles can be used to crop the image.

 

Has anyone any ideas the best way to combine the transformer with a crop behaviour, could I use the AutoFitArea Class?

 

Thanks, any ideas would be very welcome

 

Tim

Link to comment
Share on other sites

I don't think the AutoFitArea class would be of any use here, but you could certainly use TransformManager to transform a box (Shape) that has an alpha of 0, and you'd set that object as the mask of the image/object that it's supposed to be cropping. Just an idea.

Link to comment
Share on other sites

Thanks,

 

Sounds like a good idea. I'll give it a try

 

Tim

Link to comment
Share on other sites

Hi again,

 

I've come to the conclusion that my cropping tool isn't really a 'cropping' tool, but more of a resizable mask for the transform object. This is because it's based on standard libabary graphic (jpg and swf) assets and I don't want to save bitmap data back to the server for saving (just the resized mask info so I can recreate it on load form the standard library asset).

 

So..

 

If I create 2 layers within a container object that is a transform item (SkinnableContainer in Flex??). The top layer in the container as the mask and the bottom one as the original asset. Can I get the transformer to only snap to the mask layer size and not the larger original asset underneath. This will give me a non destructive crop/mask tool.

 

also.. What’s the best/lightest container for layers of graphics in Flex 3.5 and Flex 4? Any ideas?

 

Thanks!

Link to comment
Share on other sites

Can I get the transformer to only snap to the mask layer size and not the larger original asset underneath. This will give me a non destructive crop/mask tool.

 

Nope, not really. That would require a LOT of tricky customization.

 

What’s the best/lightest container for layers of graphics in Flex 3.5 and Flex 4? Any ideas?

Frankly I strongly dislike Flex and try to avoid it as much as possible, so I couldn't tell you for sure. Maybe UIComponent but you need to do some customization inside of whatever class you extend it with so that it reports its size properly (another joy of using Flex). Most Flex objects are pretty heavyweight. Sorry - I guess that wasn't much help. Maybe a Flex guru can chime in here and offer some advice.

Link to comment
Share on other sites

  • 2 weeks later...

Ok I've found a very simple solution for a non destuctive (transformable) crop in Flex.

 

Each image added to stage is should be contained within a 'Canvas' component. This canvas compoent can be transformed as normal with the transform manager which scales and rotates correctly.

 

When you need to crop the contained image either move the contained image left or above the canvas (cropping the left and the top of the image repectivly) and/or reduce the width or height of the Canvas to crop the right and bottom of the contained image.

 

That's pretty much it, no messing about with copyPixels and BitmapData like I started to do!

 

Hope it helps someone else out.

 

Tim

 

If things start to get really complicated, your'e probably doing it the wrong way

Link to comment
Share on other sites

Super! Thanks for sharing the tip, Tim.

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×