Jump to content
GreenSock

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

TM behind a mask...

Recommended Posts

I have a simple TM applied to a display object that has a mask applied to it (both are inside the same parent).

 

The area of the mask is very small compared to the actual display object that is being TM'd.

 

While I can see the handles through to the top, I can only click and drag if I select within the area of the mask. I am able to grab the handles on the edge for scale and rotation, but a drag move can only be done if I select inside the mask.

 

I have told TM to ignore the mask and I have also set the mouseEnabled property of the mask object to false.

 

Any other ideas as to how I can enable click and drag anywhere within the handle region that's visible - ignoring the mask?

 

Thanks!

Link to comment
Share on other sites

Hmmm...I think that may just be a Flash issue regarding the way it handles MouseEvents with masked objects. In other words, Flash thinks to itself "if this thing is masked, I shouldn't allow clicks on the areas outside the mask, so I'll ignore everything out there in terms of MouseEvents". I wish there was an easy solution, but I'm not aware of one right now. 

 

You could try setting alpha to 0 on your object and then artificially create the masking effect by blitting with BitmapData, but that'd be pretty cumbersome. Or create a dummy object that's transparent and the same size/position as your original and put it on top and then listen for MouseEvents on that and act accordingly on the real object via code. Again, not ideal, I know. 

Link to comment
Share on other sites

Rats - I was hoping for an easier solution. Thanks for the quick ideas!

Link to comment
Share on other sites

Hey - for those that ever run into this situation, I've figured out a really simple stupid fix. I am an idiot for not thinking of it before.

 

Here's what you do:

Create a dummy copy of the object you are wanting to transform and make sure it's at the top of the display list of the parent your other object is shared with - but make the dummy object transparent. Then, instead of applying the TM to the real object, only apply it to the dummy object on top and create an ENTER_FRAME listener that basically copies the x, y, scaleX, scaleY, and rotation values of the dummy object to the actual object you are wanting to transform.

 

And there you go! Now you can do whatever masking magic you want without having to worry about mouse events getting blocked!

 

Good times!

  • Like 1
Link to comment
Share on other sites

Great idea! Thanks for sharing. 

Link to comment
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.

×