0

我正在学习 Pixel Bender。我有一个过滤器,我想要补间的参数。据我所知,为了补间像素弯曲参数,我需要补间一个数字对象并将补间数字对象分配为着色器数据的数组值。

我确信以下方法会起作用,但似乎 Number 类没有 value 属性,所以我不知道在为 number 对象设置新补间时要使用什么属性:

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];
    }
4

1 回答 1

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);
//...

-- 或者更新你的设置器

//...
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);
//...
于 2010-03-04T11:29:31.010 回答