0

I am unable to setTitle Text for ccui.Buttona a widget, its showing cannot read property 'setTitleText' of undefined in Cocos2d-JS

Here's the code

    SolutionGrid.setEmptySolutionBox = function(selChild,rChar) {

    selChild.active = true;
    cc.log("get tag of empty solutionBpx" + selChild.getTag());
    var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));
    //var textButtons = ccui.Button(selChild.getChildren()[0]);
    if(textButtons===null){
        cc.log("get tag of empty solutionBpx NULL");
    }
    ///cc.log("get tag of empty solutionBpx" + textButtons.getTag());
    textButtons.setTitleText("a");

};

where selChild is node on which ccui.Button is added

Here how its added , I am getting the tag of that node but can not find the ccui.Button as its child

solBox.addChild(textButton,5,5); //solBox is CCNode and text button is ccui.Button
Khaled.K
  • 5,828
  • 1
  • 33
  • 51
user1169079
  • 3,053
  • 5
  • 42
  • 71
  • what is ccui? Where is it declared, initialized? – CodeSmile Nov 17 '14 at 18:41
  • @LearnCocos2D: ccui.Button is the http://www.cocos2d-x.org/reference/html5-js/V3.0alpha/symbols/ccui.Button.html .. It is intiliazed i.e. textButton i just gave a snippet and added as a child of Node (solBox) with tag 5 – user1169079 Nov 17 '14 at 19:17

1 Answers1

0

change

var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));

with

var textButtons = selChild.getChildByTag(5);
musikov
  • 640
  • 1
  • 4
  • 13