我确信以下方法可行,但似乎Number类没有value属性,所以我不知道在为数字对象设置新的补间时要使用什么属性:
import fl.transitions.*;
import fl.transitions.easing.*
var shader:Shader;
var shaderFilter:ShaderFilter;
var motionTween:Tween;
var tweenNumber:Number = new Number(0.0);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, dataLoaded);
loader.load(new URLRequest("PBFilter.pbj"));
function dataLoaded(e:Event):void
{
loader.removeEventListener(Event.COMPLETE, dataLoaded);
shader = new Shader(e.target.data);
shaderFilter = new ShaderFilter(shader);
flower.filters = [shaderFilter];
motionTween = new Tween(tweenNumber, "value", Bounce.easeOut, 0.0, 100.0, 5, true);
motionTween.addEventListener(TweenEvent.MOTION_CHANGE, updateFilter);
}
function updateFilter(e:TweenEvent):void
{
shader.data.amount.value = [tweenNumber];
myMovieClip.filters = [shaderFilter];
}
答案 0 :(得分:3)
也许您可以为补间添加一个getter和setter到您的测试类中:
//...
public function get amount():Number {
return tweenNumber;
}
public function set amount(value:Number):void {
tweenNumber=value;
}
//...
motionTween = new Tween(this, "amount", Bounce.easeOut, 0.0, 100.0, 5, true);
motionTween.addEventListener(TweenEvent.MOTION_CHANGE, updateFilter);
//...
- 或更新到您的setter
//...
public function get amount():Number {
return tweenNumber;
}
public function set amount(value:Number):void {
tweenNumber=value;
shader.data.amount.value = [value];
myMovieClip.filters = [shaderFilter];
}
//...
motionTween = new Tween(this, "amount", Bounce.easeOut, 0.0, 100.0, 5, true);
//...