access child view inside the main view in CommonJs module

Current situation: i build a module containing with a view containing a button and two views:

  function moreButtonView(){
var self=Ti.UI.createView({
    height:350,
    top:-322,
    width:Ti.UI.FILL

});
var info=Ti.UI.createView({
    height:322,
    width:Ti.UI.FILL,
    top:0,
    backgroundColor:'#bbbbbb'

});
var infoShadow=Ti.UI.createView({
    height:322,
    width:Ti.UI.FILL,
    top:3,
    backgroundColor:'#000000',
    opacity:0.3

});

var btn= Ti.UI.createButton({
    backgroundImage:'/images/controls/pulldown_btn.png',
    bottom:0,
    left:10,
    height:28,
    width:49
})
self.add(infoShadow);
self.add(info);

self.add(btn);

Ti.API.info('bg-pulldow= '+ self.getBackgroundImage());
return self;
}
module.exports=moreButtonView;

after including it into the app.js i added an eventhandler to app.js that animates a sliding out or in of that view. now, on the press of the button the view gets animated and slides in from top. works.

but how can i access the opacity of 'infoshadow'?

I'm not that fluent in javascript (yet), would be nice if someone could explain it to me.

Thanks, Jan


In your commonjs module:

self.setShadowOpacity = function(opacity){
     infoShadow.opacity = opacity;
};

in your app.js

instanceNameOfYourModule.setShadowOpacity(0.5);
链接地址: http://www.djcxy.com/p/96610.html

上一篇: 钛加速器; CommonJS没有办法

下一篇: 在CommonJs模块的主视图中访问子视图