Jump to content
GreenSock

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

Cropping constrainScale?

Recommended Posts

Once again .. thanks for an awesome code, that really helps me out on a day to day basis :D
 

Right now, I'm working on a project using the crop-functions, and I have a few questions, that I can't seem to find any answers to on the forums, or on Google.

 

First off, when I add a item that use the crop-function, is it somehow possible to have the scaling default to constraining scale? I can't seem to call the constrainScale:Boolean -property, that I usually use in a transform item. - so I guess it's not there ... but if I hold down shift, I can see the functionality is there!

 

Secondly, is there by chance a boolean to toggle the mouse-click that activates the cropping?
Since I was planing to make cropping occur only when the user clicks on a button, while the item is selected, and not being able to activate it by double-clicking.

 

Are there any way to do this without changes to the source?

p.s. you guys rocks!

Link to post
Share on other sites

I made a workaround for the constrainScale-issue, where I toggle the boolean in the transformManager itself, based on what item is selected, and if it's allowed to scale disproportionately or not ... this works, but I guess I have to fiddle with the Crop.as source, if I want it as a property on the crop-item itself, right?

Link to post
Share on other sites

Well, the Crop instance is basically like a Sprite that gets managed by the TransformManager just like any other item, so you can either set the constrainScale on the TransformManager itself, or you can get the TransformItem that's associated with the Crop instance itself, and then set the constrainScale on that. Remember, you can use yourTransformManger.getItem(yourDisplayObject) to get the TransformItem. 

Link to post
Share on other sites

Thanks for the answer :) I think i might just have figured out how to do most of the stuff I was planing.

But I do have one question, relating to this..

I'm trying to do a object that has constrainScale=true, but when in cropMode, it'll change to constrainScale=false.

I figures that I have to set up a eventListener, to listen for the "enterCropMode" and "
exitCropMode"-events, but I can't seem to figure out how to get it to work!

 

Could you write me a simple example of how to listen for the event?

 

var myItem:Crop=new Crop(myFoto, TransformManager)
myItem.addEventListener(???, cropOn)
function cropOn(???):void{
trace("Crop is on!")
}

... I might be getting it all wrong - lol 

Link to post
Share on other sites

Sure, it should look something like:

yourCrop.addEventListener("enterCropMode", yourFunction);
function yourFunction(e:Event):void {
    trace("entered crop mode");
}

And the event's "target" property would point to yourCrop of course. Does that help?

Link to post
Share on other sites

Thanks :) I just gave it a swirl, and it works like a charm.
Now I finally made the crop items behave, so that it constrain proportions when resized, and don't constrain when cropping :)
Thanks :)

  • Like 1
Link to post
Share on other sites

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.

×