Monday, June 23, 2008

Scale9Grid Class for Masking in AS3

UPDATE: Revised classes and test files can be found here.

---------------------------------------------------------------------------------

I ran into another quirk with Flash today. I couldn't get Flash to apply Scale9Grid correctly on sprites/movieclips that were being used as Masks. After searching for help it seems as though the two features are not compatible (please correct me if I am wrong). Therefore, I threw a class together this afternoon that creates a Rectangle with rounded corners that automatically scales according to the scale9Grid rules. The class allows you to use the rounded rectangle as a mask without having the corners distort when it scales.

Its nothing fancy and when I wrote it I didn't intend it for the public population. However, I haven't been good at donating code so I figured I should throw it out there anyways. Hopefully it will help me start a habit of publishing my code, which should improve my coding practices and maybe even help someone in the process.

View the source code here.

Feel free to use/edit/demolish the code and as always feedback is greatly appreciated.

9 comments:

  1. thanx for sharing. but, i think you have a test fla for your issue. could you share it cus i didnt get this class exactly.

    ReplyDelete
  2. thanks for the feedback. I make a Test.fla, swf, and make a few fixes to the class. Figured it would be easier to just to make a new post:
    http://blog.ickydime.com/2008/07/update-scale9grid-class.html

    ReplyDelete
  3. Hi!

    I had the same problem with the combination mask-9slice. Then I found this other solution: a movieclip inside a movieclip:
    http://dreamweaverforum.info/flash/11307-mask-9-slice-scaling.html

    ReplyDelete
  4. @ liflaf
    Thanks for the link! Definitely sounds like a simpler solution.

    ReplyDelete
  5. This is awesome! Thanks for contributing!

    ReplyDelete
  6. thank you so much!!!
    works perfectly for me :D...

    ReplyDelete