mx.effects.Tweenã¯ã©ã¹ãActionScriptããã¸ã§ã¯ãã§ä½¿ã£ã¦ã¿ãã
Flash8ã®ã¨ãã«ãã£ãTweenã¯ã©ã¹ã¿ããã®AS3ã«ãããã®ããªããã¨çºãã¦ã¿ãã¨ãããmxããã±ã¼ã¸ã«ä¼¼ããããªãã®ãçºè¦ããã®ã§è©¦ãã«ä½¿ã£ã¦ã¿ã¾ãããã¡ãã£ã¨ä½¿ãåæã¯ãããªãã®ã§ãããã©ããä¸è¨ã®ãããªã¯ã©ã¹ï¼é常ã«é©å½ã§ããï¼ã¨ãä¸åæ¸ãã¦ããã°ã»ãã®ã¡ãã£ã¨ããå ´é¢ã§ã¯ãããªãã«ä½¿ãããã
ãã ããActionScriptããã¸ã§ã¯ãã§mxããã±ã¼ã¸ã®ã¯ã©ã¹ã使ãå ´åã¯ããããã¨é¢åãããã¾ãã¦ãã³ã³ãã¤ã«åã«ããã¸ã§ã¯ãã®ã©ã¤ãã©ãªãã¹ã«ä»¥ä¸ã®ãã®ãå ããå¿ è¦ããã模æ§ã
${FRAMEWORKS}/libs/framework.swc
ã§ããã¾ãæ´ã£ã¦ãªãã§ããã½ã¼ã¹ã
package { import mx.effects.easing.Linear; import mx.effects.Tween; public class TweenGenerator { private var target:Object; private var prop:String; public function TweenGenerator( targetObj:Object, targetProp:String, start:Number=0, end:Number=1, duration:Number=1000, easingFunc:Function=null) { if(easingFunc==null){ easingFunc=mx.effects.easing.Linear.easeOut; } target=targetObj; prop=targetProp; var tween:Tween=new Tween(this,start,end,duration); tween.easingFunction=easingFunc; tween.setTweenHandlers(tweenUpdate,tweenEnd); } private function tweenUpdate(val:Number):void{ target.visible=true; target[prop]=val; } private function tweenEnd(val:Number):void{ delete(this); } } }
使ãæ¹
var tw:TweenGenerator=new TweenGenerator( this, //ãã¥ã¤ã¼ã³ããããªãã¸ã§ã¯ã(Object) "y", //âã®ãªãã¸ã§ã¯ãã®ãã¡ãã¥ã¤ã¼ã³ãããããããã£åï¼String) 0,//æåã®å¤ (Number) 500,//ãã¥ã¤ã¼ã³å®äºæã®å¤ (Number) 1000,//ãã¥ã¤ã¼ã³ãããæé(ããªç§ï¼(Number) mx.effects.easing.Elastic.easeOut //ãã¥ã¤ã¼ã³ãããæã®å¹æãã¤ããããã®é¢æ°(Function) );
âã®ããã«ããã¨ãthisã®yã0ãã500ã«å¤åãããã¨ã
ã¡ãªã¿ã«ãã¡ã£ã¨æ¡å¼µããã°ãã¥ã¤ã¼ã³çµäºæã«ã¤ãã³ãçºçãããã¨ããã¢ãã¡ã¼ã·ã§ã³ã®é£çµã¨ããè¤æ°ããããã£åæã³ã³ããã¼ã«ã¨ãããããã®ãã§ãããã§ãã