Last active
December 27, 2015 07:38
-
-
Save andy0130tw/7289937 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
public var throttle:Function = function (fn:Function, delay:Number):Function { | |
var timer:* = null; | |
return function ():void { | |
var context:Object = this, args:Object = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(function ():void { | |
fn.apply(context, args); | |
}, delay); | |
}; | |
public function init():void{ | |
this.addEventListener("resize",throttle(function(event:Event){ | |
//resize,zmTween是自訂的轉場動畫 | |
//WW是舞台預設寬,HH是舞台預設高 | |
if(zmTween.isPlaying)zmTween.stop(); | |
zmTween.scaleYFrom=cv.scaleY; | |
zmTween.scaleXFrom=cv.scaleX; | |
zmTween.scaleXTo=zmTween.scaleYTo=this.width/this.height<WW/HH?this.width/WW:this.height/HH; | |
zmTween.play([cv]); | |
},250)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment