dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Skewing an MC through actionscript

  1. #1
    Member
    Join Date
    Jan 2006
    Posts
    82

    Skewing an MC through actionscript

    In AS 2.0, is there any way to skew a movieclip through actionscript so that it is in the shape of a trapezoid?

    Like so:

    __
    / \
    ---
    Last edited by panthoz; 07-09-2009 at 04:27 PM.

  2. #2
    Senior Member fil_razorback's Avatar
    Join Date
    Jul 2005
    Location
    Paris, France
    Posts
    607
    I assume you're using AS2. Here's what you're looking for : http://docs.brajeshwar.com/as2/
    The flash.geom.Matrix class represents a transformation matrix that determines how to map points from one coordinate space to another. By setting the properties of a Matrix object and applying it to a MovieClip or BitmapData object you can perform various graphical transformations on the object. These transformation functions include translation (x and y repositioning), rotation, scaling, and skewing.
    'hope this helps.

    EDIT after your edit :
    more friendly text here : http://www.senocular.com/flash/tutor...ansformmatrix/
    But it doesnt seem to make trapez. Sorry :/
    Last edited by fil_razorback; 07-09-2009 at 04:45 PM.

  3. #3
    Member
    Join Date
    Jan 2006
    Posts
    82
    Quote Originally Posted by fil_razorback View Post
    I assume you're using AS2. Here's what you're looking for : http://docs.brajeshwar.com/as2/


    'hope this helps.

    EDIT after your edit :
    more friendly text here : http://www.senocular.com/flash/tutor...ansformmatrix/
    But it doesnt seem to make trapez. Sorry :/
    Ya unfortunately none of these do a trapezoid shape like i posted above. They only skew sideways.

  4. #4
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    well scaling to trapezoid falls in pseudo-3d group, and you can do that on a bitmap by splitting it up in triangles, and then use transform matrix on it(texture mapping)!
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  5. #5
    Member
    Join Date
    Jan 2006
    Posts
    82
    Quote Originally Posted by bluemagica View Post
    well scaling to trapezoid falls in pseudo-3d group, and you can do that on a bitmap by splitting it up in triangles, and then use transform matrix on it(texture mapping)!
    Any good examples out there of how this can be accomplished? Would it slow down gameplay much if everything is contained within the skewed MC?

  6. #6
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    MCs cannot be scaled to trapezoid only bitmaps(bitmapData) can be, so you have to convert your mc to a bitmap before you can do the transformation! And yes, this can and will affect your performance a bit, but depending on how wisely you use it, the performance hit can be negligible!

    I modified the code from this tutorial, it may look a bit daunting, but if you can just understand the matrix portion, rest is easy(I spent a few days trying to understand it, so don't give up!)
    http://board.flashkit.com/board/showthread.php?t=778852
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  7. #7
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    check:
    http://www.rubenswieringa.com/blog/distortimage
    http://www.flashsandy.org/blog/disto...ionscript.html

    it needs to be sliced into several triangles in order to do trapezoid transformations. This is because within flash all bitmap transformations are based on affine texture mapping (the skewing, rotating and scaling stuff).
    That sandy class (also AS2 available) does that for you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center