0

我正在做一个钛移动项目,我想更新一些变量。

如何更新“exports.presets”中的一些变量?这对我来说看起来很容易,但不幸的是我不能这样做..

exports.presets = {

    Filter1:new superimageview.Filter(function(){
        this.brightness(slider1.value)
            .saturation(slider2.value)
            .contrast(slider3.value)
            .channels({r:0.4,g:0.6,b:0.2});
    }),
    Filter2:new superimageview.Filter(function(){
        this.brightness(slider1.value)
            .saturation(slider2.value)
            .contrast(slider3.value)
            .channels({r:0.2,g:0.1,b:0.1});
    }),
    Filter3:new superimageview.Filter(function(){
        this.brightness(slider1.value)
            .saturation(slider2.value)
            .contrast(slider3.value)
            .channels({r:0.0,g:0.2,b:0.6});
    })
};
//



var slider1 = Titanium.UI.createSlider({
    top: 20,
    min: -0.5,
    max: 0.5,
    width: '100%',
    value: 0
    });
slider1.addEventListener('change', function(e) {

  label.text = e.value;
   // XXX What to do here?
});
4

1 回答 1

0

试试这个,假设你和你的代码一样在同一个模块中,否则删除“exports”:

slider1.addEventListener('change', function(e) {

  label.text = e.value;
   // XXX What to do here?
   // This! Update the presets with new values.
   // Im guessing slider1 coincides with Filter1
   exports.presets.Filter1 = new superimageview.Filter(function(){
        this.brightness(slider1.value)
            .saturation(slider2.value)
            .contrast(slider3.value)
            .channels({r:0.4,g:0.6,b:0.2});
   });

});

这会将预设值设置为滑块的更新值。

于 2013-07-01T03:59:48.243 回答