messing around with commonJS to see if I can write more efficient code and create common UI objects using classes defined from a commonJS module.
this is how I've set it up, for example a normal label
commonJS module
function NormalLbl (e){} NormalLbl.prototype.create = function(view, txt, rightPos, yPos){ this.lbl = Ti.UI.createLabel({ color: '#3498db', textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER, font: {fontFamily: customFont, fontSize: 46}, text: txt, right: rightPos, center: {y: yPos} //center: {y: '15%'} }); view.add(this.lbl); }; exports.NormalLbl = NormalLbl;then instantiate this class in a view
var surName = new Obj.NormalLbl(); surName.create(e, "Surname", labelRight,'45%');This is working fine so far, the object is appearing on screen and appearing correctly, but...
if I want to make some changes to that instantiated object, for example if I want to change the width or font to something else, it does not allow me, I assume because its set in stone in the constructor.
So 2 questions 1. is this the best and most efficient way to create UI objects? 2. What am I doing wrong that is stopping me from editing the instantiated objects?
Thankyou ^^