cc.Label undefined

cc.Label undefined


Hi! I’ve been working on Cocos Creator for a few months now and this was the first time I happened to encountered this problem. There were times I can’t drag my node to my cc.Label at custom component because it is said to be null.


I also got an error message where the string from getComponent(cc.Label) was unidentified.
(This is a button node with cc.Label component)

this.node.getChildByName('text').getComponent(cc.Label).string = '-';

“Uncaught TypeError: Cannot set property ‘string’ of null”

I also got a warning from the Cocos Creator console…
‘Can not instantiate CCClass ‘undefined’ with argument’
…which is probably meant for cc.Label.


Maybe you should describe a little bit more what you are trying to do.

So all these Btn Interval, Btn Pair, Btn Technical etc. are Properties of the Type cc.Label, right?
You need cc.Label and not Strings?

So I don’t really get what you are trying to do but maybe you just have to instantiate all these cc.Label properties (onLoad).


Thank you for the reply. Yes, all of the properties were in type cc.Label.
Actually this was working before until all of the cc.Label properties in all of my scripts became undefined. I instantiate all my labels to onLoad method.

My guess was that cc class doesn’t recognized the cc.Label and becomes undefined.


Do you mean with an older version of Cocos Creator?


It wasn’t working after I installed the latest version of Cocos Creator.


I’m using CC v2.0.2 and initializin my “properties” like

start: function () {
   if(this.xy == null || this.xy == undefined) {
      this.xy = cc.Label.create...

that seems to be okay. no runtime errors. but maybe someone else (cc dev) can help you better.


This problem was already fixed but still I don’t know the exact solution for this problem but these were the steps I did before it worked.

  1. Create new project.
  2. Add cc.Label property to the script.
  3. Drag the label to the custom component with your script (if doesn’t gives null like from the photo above).
  4. Reopen Cocos Creator.
  5. Go back to your previous project and see if cc.Label is working.


i am also facing that issue. have you solved it?