As3 Flip Vertical and Flip Horizontal

8 Responses to “As3 Flip Vertical and Flip Horizontal”

  1. kevincao Says:

    Hi, Thank u for sharing. I’ve post it to my blog for reference and send a trackback to you.
    http://kevincao.com/2008/06/17/as3-flip-vertical-and-flip-horizontal

  2. piggy Says:

    Very nice example, but i have trouble:
    when i’m trying to flip object with text (i.e. label, button) I don’t see text after flipping.
    After appplying flip once more, text appear back.
    Any suggestions ?

  3. piggy Says:

    ah…
    sorry :)
    If you want to do something like flip with objects with text, you must use embed fonts.

  4. Idoru Says:

    Yes, otherwise the fonts aren’t eligible to be rasterized into bitmaps.

  5. xleon Says:

    Hi, I´m not sure what your code does, but I think it´s easier like this:

    vertical:
    dsp.scaleY = -dsp.scaleY;

    horizontal:
    dsp.scaleX = -dsp.scaleX;

  6. g Says:

    xleon,

    Your method doesn’t work with video, while the others do.

  7. Michael Says:

    to switch back and forth, use this:

    function flipHorizontal(dsp:DisplayObject):void
    {
    var matrix:Matrix = dsp.transform.matrix;
    //matrix.a = -1;
    matrix.a *= -1;
    //matrix.tx = dsp.width + dsp.x;
    matrix.tx = -matrix.a * dsp.width + dsp.x;
    dsp.transform.matrix = matrix;
    }

    function flipVertical(dsp:DisplayObject):void
    {
    var matrix:Matrix = dsp.transform.matrix;
    //matrix.d = -1;
    matrix.d *= -1;
    matrix.ty = -matrix.d * dsp.height + dsp.y;
    //matrix.ty = dsp.height + dsp.y;
    dsp.transform.matrix = matrix;
    }

  8. Eric Brito Says:

    Does anyone know how the Michael’s code woulde be if the image had a bigger or smaller scale and a rotation angle?

Leave a Reply