Loosing children interactivity after setting perspectiveProjection

Monday, January 25th, 2010

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

My current project needs to use new native 3D in Flash Player 10. It seems so easy to use it, just set any 3d property like x,y,z or rotationX, rotationY, rotationZ and all should work perfectly. It seems so. But I have found problem and it seems it’s Flash player bug (I hope someone proves me wrong :) ). I need to change field of view of some DisplayObject to have different perspective as it is set by default. So I’ve done it in way

var pp:PerspectiveProjection = new PerspectiveProjection();
pp.fieldOfView = 11;
 
this.transform.perspectiveProjection = pp;

it’s easy and it works. But problem is, that after setting of perspectiveProjection all children interactivity (mouse click, rollovers and rollouts) stops working :( and this is really big issue. I’ve tried everything I know to prevent this, but I could not make it work. So I’m trying to write this post to get help on this (if it is possible).

Let me know if you have similar problem and please vote for Adobe bug(s) I will post later to let Adobe fix it ASAP.

Some links with this issue on net:

Let me know if comments if you know anything about this problem. Thank you

tagged under: .....

ABOUT THIS AUTHOR

Get a Trackback link

2 Trackbacks/Pingbacks

  1. Trackback: uberVU - social comments on February 3, 2010
  2. Pingback: FlashPlayer10 3D blockiert MouseEvents?! - Flashforum on June 7, 2010

2 Comments


  1. Barbara Kaskosz
    Visit Site
    January 25th, 2010

    Hi Franto,
    The answer to your question is to create a 2D container for your interactive object and to assign a custom PerspectiveProjection to the container and not to the object itself. Below is the code in a file PPTest.as that I assigned as the Document Class to a fla file (with 550 by 400 stage). Everything works fine.
    /*
    ActionScript 3 Tips by Barbara Kaskosz.

    http://www.flashandmath.com

    Last modified: January 25, 2010.

    */

    package {

    import flash.display.Sprite;

    import flash.events.MouseEvent;

    import flash.geom.PerspectiveProjection;

    import flash.geom.Point;

    public class PPTest extends Sprite {

    private var container:Sprite;

    private var square:Sprite;

    private var pp:PerspectiveProjection;

    public function PPTest(){

    container=new Sprite();

    this.addChild(container);

    container.x=400;

    container.y=60;

    square=new Sprite();

    container.addChild(square);

    square.x=50;

    square.y=50;

    drawSquare();

    square.addEventListener(MouseEvent.CLICK,squareClicked);

    square.rotationY=45;

    pp=new PerspectiveProjection();

    pp.fieldOfView=80;

    pp.projectionCenter=new Point(50,50);

    container.transform.perspectiveProjection=pp;

    /*
    Assigning pp to square instead of container,
    as in the next line, makes square lose interactivity.
    */

    //square.transform.perspectiveProjection=pp;

    /*
    Making container a 3D object by uncommenting the
    next line obliterates effects of pp.
    */

    //container.z=0;

    }

    private function drawSquare():void {

    var color:Number=Math.random()*0xFFFFFF/2;

    square.graphics.clear();

    square.graphics.beginFill(color);

    square.graphics.drawRect(-50,-50,100,100);

    square.graphics.endFill();

    }

    private function squareClicked(e:MouseEvent):void {

    drawSquare();

    }

    }

    }

    PespectiveProjection behaves counterintuitively in many ways. See for example:
    http://www.flashandmath.com/flashcs4/pp/
    Today I am working on another post for Flash and Math about quirky behavior of PerspectiveProjection.
    Take care, Franto. It is nice to be in touch with you.
    Barbara
    Barbara Kaskosz´s last blog ..A Dramatic 3D Image Gallery in AS3 Flash Player 10 My ComLuv Profile


  2. admin
    Visit Site
    January 26th, 2010

    Barbara, thank you for your help. It works :)

    But i’m curious, if this is just hack or this is how it should work, because it’s not very intuitive :)

Live Preview

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

CommentLuv Enabled

Images is enhanced with WordPress Lightbox JS by Zeo