ngchenghow

setSize rather than width/height

Recommended Posts

Hi,

 

I'm using a complex class(like a component) as a target object for transform manager, is that anywhere to let TM to change it's size with setSize method rather than change on width and height directly?

 

 

Thanks.

Share this post


Link to post
Share on other sites

Or is it some place in your code I can change to make call my own methods rather than width/height/rotation/x/y ?

Share this post


Link to post
Share on other sites

Sure, it's in TransformItem's scaleRotated() method, where these lines are:

 

_targetObject.width = w;
_targetObject.height = h;

Share this post


Link to post
Share on other sites

That functionality isn't currently supported, but you could edit the Crop class so that it targets a generic Sprite instance that is exactly the same size (natively) as your target image and then use it as a proxy of sorts so that whenever that Sprite gets moved/resized/rotated, you figure out its width and height and then feed it into your object's special function(s) like setSize().

Share this post


Link to post
Share on other sites

Thanks for your input !

 

I did edited Crop.as, adding

 

public var cropWidth:Number
public var cropHeight:Number

 

and edited

 

protected function _calibrateBox():void {
  var bounds:Rectangle = _target.getBounds(_target);
  var g:Graphics = _mask.graphics;
  g.clear();
  g.beginFill(0xFF0000, 1);
  g.drawRect(bounds.x, bounds.y, cropWidth, cropHeight);
  g = this.graphics;
  g.clear();
  g.beginFill(_fillColor, 1);
  g.drawRect(bounds.x, bounds.y, cropWidth, cropHeight);
  trace("_calibrateBox")
 }

 

A bit of a hack since its work in progress but that works so far

Share this post


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.