package com.greensock.plugins { import com.greensock.*; import com.greensock.core.*; public class BezierPlugin extends com.greensock.plugins.TweenPlugin { public function BezierPlugin() { this._future = {}; super(); this.propName = "bezier"; this.overwriteProps = []; return; } public override function onInitTween(arg1:Object, arg2:*, arg3:com.greensock.TweenLite):Boolean { if (!(arg2 as Array)) { return false; } this.init(arg3, arg2 as Array, false); return true; } protected function init(arg1:com.greensock.TweenLite, arg2:Array, arg3:Boolean):void { var loc3:*; loc3 = 0; var loc4:*; loc4 = null; var loc5:*; loc5 = null; this._target = arg1.target; var loc1:*; if ((loc1 = arg1.vars.isTV != true ? arg1.vars : arg1.vars.exposedVars).orientToBezier != true) { if (loc1.orientToBezier as Array) { this._orientData = loc1.orientToBezier; this._orient = true; } } else { this._orientData = [["x", "y", "rotation", 0, 0.01]]; this._orient = true; } var loc2:*; loc2 = {}; loc3 = 0; while (loc3 < arg2.length) { var loc6:*; loc6 = 0; var loc7:*; loc7 = arg2[loc3]; for (loc4 in loc7) { if (loc2[loc4] == undefined) { loc2[loc4] = [arg1.target[loc4]]; } if (typeof arg2[loc3][loc4] == "number") { loc2[loc4].push(arg2[loc3][loc4]); continue; } loc2[loc4].push(arg1.target[loc4] + Number(arg2[loc3][loc4])); } ++loc3; } loc6 = 0; loc7 = loc2; for (loc4 in loc7) { this.overwriteProps[this.overwriteProps.length] = loc4; if (loc1[loc4] == undefined) { continue; } if (typeof loc1[loc4] != "number") { loc2[loc4].push(arg1.target[loc4] + Number(loc1[loc4])); } else { loc2[loc4].push(loc1[loc4]); } (loc5 = {})[loc4] = true; arg1.killVars(loc5, false); delete loc1[loc4]; } this._beziers = parseBeziers(loc2, arg3); return; } public override function killProps(arg1:Object):void { var loc1:*; loc1 = null; var loc2:*; loc2 = 0; var loc3:*; loc3 = this._beziers; for (loc1 in loc3) { if (!(loc1 in arg1)) { continue; } delete this._beziers[loc1]; } super.killProps(arg1); return; } public override function set changeFactor(arg1:Number):void { var loc1:*; loc1 = 0; var loc2:*; loc2 = null; var loc3:*; loc3 = null; var loc4:*; loc4 = NaN; var loc5:*; loc5 = 0; var loc6:*; loc6 = NaN; var loc7:*; loc7 = null; var loc8:*; loc8 = NaN; var loc9:*; loc9 = NaN; var loc10:*; loc10 = null; var loc11:*; loc11 = NaN; var loc12:*; loc12 = null; var loc13:*; loc13 = false; if (arg1 != 1) { loc14 = 0; loc15 = this._beziers; for (loc2 in loc15) { loc5 = this._beziers[loc2].length; if (arg1 < 0) { loc1 = 0; } else { if (arg1 >= 1) { loc1 = (loc5 - 1); } else { loc1 = int(loc5 * arg1); } } loc4 = (arg1 - loc1 * 1 / loc5) * loc5; loc3 = this._beziers[loc2][loc1]; if (this.round) { loc6 = loc3[0] + loc4 * (2 * (1 - loc4) * (loc3[1] - loc3[0]) + loc4 * (loc3[2] - loc3[0])); this._target[loc2] = loc6 > 0 ? int(loc6 + 0.5) : int(loc6 - 0.5); continue; } this._target[loc2] = loc3[0] + loc4 * (2 * (1 - loc4) * (loc3[1] - loc3[0]) + loc4 * (loc3[2] - loc3[0])); } } else { var loc14:*; loc14 = 0; var loc15:*; loc15 = this._beziers; for (loc2 in loc15) { loc1 = (this._beziers[loc2].length - 1); this._target[loc2] = this._beziers[loc2][loc1][2]; } } if (this._orient) { loc1 = this._orientData.length; loc7 = {}; while (loc1--) { loc10 = this._orientData[loc1]; loc7[loc10[0]] = this._target[loc10[0]]; loc7[loc10[1]] = this._target[loc10[1]]; } loc12 = this._target; loc13 = this.round; this._target = this._future; this.round = false; this._orient = false; loc1 = this._orientData.length; while (loc1--) { loc10 = this._orientData[loc1]; this.changeFactor = arg1 + (loc10[4] || 0.01); loc11 = loc10[3] || 0; loc8 = this._future[loc10[0]] - loc7[loc10[0]]; loc9 = this._future[loc10[1]] - loc7[loc10[1]]; loc12[loc10[2]] = Math.atan2(loc9, loc8) * _RAD2DEG + loc11; } this._target = loc12; this.round = loc13; this._orient = true; } return; } public static function parseBeziers(arg1:Object, arg2:Boolean=false):Object { var loc1:*; loc1 = 0; var loc2:*; loc2 = null; var loc3:*; loc3 = null; var loc4:*; loc4 = null; var loc5:*; loc5 = {}; if (arg2) { var loc6:*; loc6 = 0; var loc7:*; loc7 = arg1; for (loc4 in loc7) { loc2 = arg1[loc4]; var loc8:*; loc3 = loc8 = []; loc5[loc4] = loc8; if (loc2.length > 2) { loc3[loc3.length] = [loc2[0], loc2[1] - (loc2[2] - loc2[0]) / 4, loc2[1]]; loc1 = 1; while (loc1 < (loc2.length - 1)) { loc3[loc3.length] = [loc2[loc1], loc2[loc1] + loc2[loc1] - loc3[(loc1 - 1)][1], loc2[(loc1 + 1)]]; ++loc1; } continue; } loc3[loc3.length] = [loc2[0], (loc2[0] + loc2[1]) / 2, loc2[1]]; } } else { loc6 = 0; loc7 = arg1; for (loc4 in loc7) { loc2 = arg1[loc4]; loc3 = loc8 = []; loc5[loc4] = loc8; if (loc2.length > 3) { loc3[loc3.length] = [loc2[0], loc2[1], (loc2[1] + loc2[2]) / 2]; loc1 = 2; while (loc1 < loc2.length - 2) { loc3[loc3.length] = [loc3[(loc1 - 2)][2], loc2[loc1], (loc2[loc1] + loc2[(loc1 + 1)]) / 2]; ++loc1; } loc3[loc3.length] = [loc3[(loc3.length - 1)][2], loc2[(loc2.length - 2)], loc2[(loc2.length - 1)]]; continue; } if (loc2.length == 3) { loc3[loc3.length] = [loc2[0], loc2[1], loc2[2]]; continue; } if (loc2.length != 2) { continue; } loc3[loc3.length] = [loc2[0], (loc2[0] + loc2[1]) / 2, loc2[1]]; } } return loc5; } public static const API:Number=1; protected static const _RAD2DEG:Number=180 / Math.PI; protected var _target:Object; protected var _orientData:Array; protected var _orient:Boolean; protected var _future:Object; protected var _beziers:Object; } }