Created
September 2, 2010 20:56
-
-
Save hankpillow/562932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aze.motion.specials | |
{ | |
import aze.motion.EazeTween; | |
import aze.motion.specials.EazeSpecial; | |
import flash.geom.* | |
/** | |
* scrollRect as eaze property | |
* @author igor almeida ialmeida.com/ | |
* @usage | |
* eaze(sprite).to(1,{"_scrollRect":new Rectangle(100,0,100,100)}) | |
*/ | |
public class PropertyScrollrect extends EazeSpecial | |
{ | |
static public function register():void | |
{ | |
EazeTween.specialProperties["_scrollRect"] = PropertyScrollrect; | |
} | |
private var original : Rectangle; | |
private var targetRect : Rectangle | |
private var hasScrollRect : Boolean; | |
private var tmpRect : Rectangle; | |
public function PropertyScrollrect(target:Object, property:*, value:*, next:EazeSpecial):void{ | |
super(target, property, value, next); | |
targetRect = value ? value is Rectangle ? value : new Rectangle : new Rectangle | |
} | |
override public function init(reverse:Boolean):void | |
{ | |
tmpRect = new Rectangle; | |
var rect : Rectangle = target.hasOwnProperty("scrollRect") ? target.scrollRect is Rectangle ? target.scrollRect.clone() : new Rectangle : new Rectangle; | |
if (reverse){ | |
original = target.clone(); | |
targetRect = rect.clone(); | |
}else{ | |
original = rect.clone(); | |
} | |
} | |
override public function update(ke:Number, isComplete:Boolean):void | |
{ | |
if (target.hasOwnProperty("scrollRect")){ | |
if (isComplete){ | |
target.scrollRect = targetRect; | |
} | |
else{ | |
tmpRect.x = original.x + (targetRect.x - original.x) * ke; | |
tmpRect.y = original.y + (targetRect.y - original.y) * ke; | |
tmpRect.width = original.width + (targetRect.width - original.width) * ke; | |
tmpRect.height = original.height + (targetRect.height - original.height) * ke; | |
target.scrollRect = tmpRect; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment