Jump to content
Search Community

Tween a projectionCenter point?

kaplan test
Moderator Tag

Recommended Posts

Hi,

 

Sorry, this might be a why would you want to do that question...

 

I'm wondering if it's possible to tween a projectionCenter point. Let's say I have something like the following:

perspectivePoint = root.transform.perspectiveProjection.projectionCenter = new Point(480,200);
trace(perspectivePoint.x); // traces 480

 

I have a group of objects that are at different z's and I'd like to do a subtle shift the perspective instead of rotating y or x. Is that crazy? I'm a better off just using rotationY. Is it possible and how would I tween something like the perspectivePoint.x? And have the stage's projectionCenter update itself?

 

Any advice or insight would be really great.

Thanks,

Dave

Link to comment
Share on other sites

You can tween pretty much any numeric value with TweenLite/Max, yes. Some properties in Flash, however, require that you re-apply them in a specific way in order for the changes to take effect. I'm pretty sure that's how it works with projectionCenter. You can just use an onUpdate to re-apply the Point, though, like this:

 

perspectivePoint = root.transform.perspectiveProjection.projectionCenter = new Point(480,200);
TweenLite.to(perspectivePoint, 2, {x:600, onUpdate:applyPoint});
function applyPoint():void {
   root.transform.perspectiveProjection.projectionCenter = perspectivePoint;
}

 

You could create a TweenPlugin that would do this for you instead, but it's not necessary.

Link to comment
Share on other sites

  • 2 months later...

Thanks for that guys - I've been pulling my hair out for days trying to solve a dynamically changing perspectiveProjection center - one that responded to a users mouse move. Here was my solution, thanks!

(the Box3d is a separate class that builds a box)

 

package com {

 

import flash.events.*;

import flash.display.*;

import flash.geom.*;

import com.greensock.*;

import com.common.Box3d;

 

public class DynamicProjectionCenter extends Sprite {

 

private var _box:Box3d;

private var _perspectivePoint:*;

private var _currentX:Number;

private var _currentY:Number;

 

public function Hotdraw() {

 

_box = new Box3d();

addChild(_box);

 

_currentX = this.stage.stageWidth /2;

_currentY = this.stage.stageHeight /2;

 

_box.x = _currentX - (_box.width/2);

_box.y = _currentY - (_box.height/2);;

_box.z = -1;

 

_perspectivePoint = root.transform.perspectiveProjection.projectionCenter = new Point(_currentX,_currentY);

 

stage.addEventListener(MouseEvent.MOUSE_MOVE, updatePerspective);

 

}//end constructor

 

private function updatePerspective(evt:MouseEvent):void{

 

TweenLite.to(_perspectivePoint, 1, {x:evt.stageX, y:evt.stageY, onUpdate:applyPoint});

}

 

private function applyPoint():void {

root.transform.perspectiveProjection.projectionCenter = _perspectivePoint;

}

 

}// end class

}//end package

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.
×
×
  • Create New...