最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

TweenMax.TransformAroundPointPlugin

来源:动视网 责编:小OO 时间:2025-09-25 16:31:20
文档

TweenMax.TransformAroundPointPlugin

/*as3TweenMax,TweenLite的TransformAroundCenterPlugin类是club的需要收费的这里提供的代码仅供学习用共用三个as文件*///---------------------TransformAroundCenterPlugin.as--------------///***VERSION:1.00*DATE:5/10/2010*ACTIONSCRIPTVERSION:3.0*UPDATESANDDOCUMENTATIONAT:http://www.Tw
推荐度:
导读/*as3TweenMax,TweenLite的TransformAroundCenterPlugin类是club的需要收费的这里提供的代码仅供学习用共用三个as文件*///---------------------TransformAroundCenterPlugin.as--------------///***VERSION:1.00*DATE:5/10/2010*ACTIONSCRIPTVERSION:3.0*UPDATESANDDOCUMENTATIONAT:http://www.Tw
/*

as3 TweenMax,TweenLite的TransformAroundCenterPlugin 类是club的需要收费的

这里提供的代码仅供学习用

共用三个as文件

*/

//---------------------TransformAroundCenterPlugin.as --------------//

/**

* VERSION: 1.00

* DATE: 5/10/2010

* ACTIONSCRIPT VERSION: 3.0

* UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com;

* by a?

**/

package com.greensock.plugins

{

import com.greensock.TweenLite;

import flash.geom.Matrix;

import flash.geom.Point;

import flash.geom.Transform;

public class TransformAroundCenterPlugin extends TransformAroundGridPlugin

{

/** @private **/

public static const API:Number = 1.0;

public function TransformAroundCenterPlugin()

{

super();

this.propName = "transformAroundCenter";

this.overwriteProps = ["scaleX

case 0:

_point = new Point(0, 0);

break;

case 1:

_point = new Point(target.width / 2, 0);

break;

case 2:

_point = new Point(target.width, 0);

break;

case 3:

_point = new Point(0, target.height / 2);

break;

case 4:

_point = new Point(target.width / 2, target.height / 2);

break;

case 5:

_point = new Point(target.width, target.height / 2);

break;

case 6:

_point = new Point(0, target.height);

break;

case 7:

_point = new Point(target.width / 2, target.height);

break;

case 8:

_point = new Point(target.width, target.height);

break;

}

}

value.point = new Point(_matrix.tx + _point.x * matrix.a + _point.y * matrix.c, _matrix.ty + _point.x * matrix.b + _point.y * matrix.d);

_transform.matrix = matrix;

super.onInitTween(target, value, tween);

return true;

}

}

}

//---------------------TransformAroundPointPlugin.as --------------//

/**

* VERSION: 1.00

* DATE: 5/10/2010

* ACTIONSCRIPT VERSION: 3.0

* UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com;

* by a?

**/

package com.greensock.plugins

{

import com.greensock.plugins.TransformMatrixPlugin;

import com.greensock.TweenLite;

import flash.geom.Matrix;

import flash.geom.Point;

import flash.geom.Transform;

public class TransformAroundPointPlugin extends TransformMatrixPlugin

{

/** @private **/

public static const API:Number = 1.0;

/** @private **/

private static const _DEG2RAD:Number = Math.PI / 180;

/** @private **/

private static const _RAD2DEG:Number = 180 / Math.PI;

/** @private **/

protected var _point:Point;

public function TransformAroundPointPlugin()

{

super();

this.propName = "transformAroundPoint";

this.overwriteProps = ["scaleX

scaleX = -scaleX;

}

var scaleY:Number = Math.sqrt(matrix.c * matrix.c + matrix.d * matrix.d); //Bugs in the Flex framework prevent DisplayObject.scaleY from working consistently, so we must determine it using the matrix.

if (matrix.d < 0 && matrix.a > 0) {

scaleY = -scaleY;

}

var angle:Number = Math.atan2(matrix.b, matrix.a); //Bugs in the Flex framework prevent DisplayObject.rotation from working consistently, so we must determine it using the matrix

if (matrix.a < 0 && matrix.d >= 0) {

angle += (angle <= 0) ? Math.PI : -Math.PI;

}

var finalAngle:Number = ("rotation" in value) ? (typeof(value.rotation) == "number") ? value.rotation * _DEG2RAD : Number(value.rotation) * _DEG2RAD + angle : angle;

if (finalAngle != angle) {

if ("rotation" in value) {

_angleChange = finalAngle - angle;

finalAngle = angle; //to correctly affect the skewX calculations below

} else {

matrix.rotate(finalAngle - angle);

}

}

if ("scale" in value) {

ratioX = Number(value.scale) / scaleX;

ratioY = Number(value.scale) / scaleY;

if (typeof(value.scale) != "number") { //relative value

ratioX += 1;

ratioY += 1;

}

} else {

if ("scaleX" in value) {

ratioX = Number(value.scaleX) / scaleX;

if (typeof(value.scaleX) != "number") { //relative value

ratioX += 1;

}

}

if ("scaleY" in value) {

ratioY = Number(value.scaleY) / scaleY;

if (typeof(value.scaleY) != "number") { //relative value

rati

oY += 1;

}

}

}

if (ratioX) {

matrix.a *= ratioX;

matrix.b *= ratioX;

}

if (ratioY) {

matrix.c *= ratioY;

matrix.d *= ratioY;

}

_aChange = matrix.a - _aStart;

_bChange = matrix.b - _bStart;

_cChange = matrix.c - _cStart;

_dChange = matrix.d - _dStart;

scaleX = Math.sqrt(matrix.a * matrix.a + matrix.b * matrix.b);

if (matrix.a < 0 && matrix.d > 0) {

scaleX = -scaleX;

}

scaleY = Math.sqrt(matrix.c * matrix.c + matrix.d * matrix.d);

if (matrix.d < 0 && matrix.a > 0) {

scaleY = -scaleY;

}

}

_point = ("point" in value && value.point is Point) ? Point(value.point) : new Point(_txStart, _tyStart);

_txChange = (_point.x - _txStart) * (1 - scaleX);

_tyChange = (_point.y - _tyStart) * (1 - scaleY);

return true;

}

override public function set changeFactor(n:Number):void

{

_matrix.a = _aStart + (n * _aChange);

_matrix.b = _bStart + (n * _bChange);

_matrix.c = _cStart + (n * _cChange);

_matrix.d = _dStart + (n * _dChange);

var origin:Matrix = new Matrix(1, 0, 0, 1, 0, 0);

if (_angleChange) {

_matrix.rotate(_angleChange * n);

origin.rotate(_angleChange * n);

}

_matrix.tx = _txStart + (n * _txChange);

_matrix.ty = _tyStart + (n * _tyChange);

var _disX:Number = (_matrix.tx - _point.x) * origin.a + (_matrix.ty - _point.y) * origin.c - (_matrix.tx - _point.x);

var _disY:Number = (_matrix.tx - _point.x) * origin.b + (_matrix.ty - _point.y) * origin.d - (_matrix.ty - _point.y);

_matrix.tx += _disX;

_matrix.ty += _disY;

_transform.matrix = _matrix;

}

private function getRotation(start:Number, end:Number):Number {

var diff:Number = (end - start) % 360;

if (diff != diff % 180) {

diff = (diff < 0) ? diff + 360 : diff - 360;

}

return start + diff;

}

}

}

文档

TweenMax.TransformAroundPointPlugin

/*as3TweenMax,TweenLite的TransformAroundCenterPlugin类是club的需要收费的这里提供的代码仅供学习用共用三个as文件*///---------------------TransformAroundCenterPlugin.as--------------///***VERSION:1.00*DATE:5/10/2010*ACTIONSCRIPTVERSION:3.0*UPDATESANDDOCUMENTATIONAT:http://www.Tw
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top