EditBox and WebService questions

Hello! Sorry if I’m asking this in the wrong place, but I’m really in need of some help. I’m trying to make a EditBox where I will write an access code and validate it using a online service. But the problem is, I couldn’t find any example of EditBox on Cocos JSB and I don’t know if it is possible to make my app communicate with a server in JSB. Can anyone help me out?

Thanks in advance!

1 Like

Well, I’ve found a “solution” to my EditBox problem, and I wrote it between quotes because another problem came with this solution. I’ve used the following syntax:

this.box = new cc.EditBox(cc.size(200, 200), this.img_txt1, this.img_txt1, this.img_txt1);
    this.box.attr({
    	x:200,
    	y:200
    });
    this.addChild(this.box, 50);

But now the app is crashing, I’m using cocos2d JSB 3.0 rc2 in CocosCode IDE. Does anyone know what’s wrong? And any clues about the server communication issue?

You can refer to the example in the test cases which located in your downloaded package: samples/js-tests/src/ExtensionsTest/EditBoxTest/EditBoxTest.js

And what you have done wrong in you code is probably that your this.img_txt1 etc isn’t a cc.Scale9Sprite object.

1 Like

Thanks for your reply! I’ll take a look there! And that’s right, my this.img_txt1 is a cc.Sprite, my bad. And about the server communication issue, is there any way I could communicate my native app with a server?

Thanks for your time!

Well, I made some tests here, and I wasn’t expecting a input dialog (debugging on win32). And I couldn’t make cc.Scale9Sprite work on the browser, perhaps that’s my mistake. Is there an alternative to EditBox? Or is there a way to disable the input dialog? And, last but not least, should Scale9Sprite work on the browser?

You can use XMLHTTPRequest, it’s available in JSB also

1 Like

Ok! I’ll use it then, thanks a lot!

Now the only problem left is the EditBox one…

Thank you for your time!

I’ve found something about cc.TextFieldTTF, and I decided to try it out, but I can’t make it work. Perhaps it’s not supported in JSB? Here’s my code:

this.txtf1 = cc.TextFieldTTF('test', "Arial", 32);
    this.txtf1.attr({
    	x: 358,
    	y: 225
    });
    this.addChild(this.txtf1, 100);

Is something wrong with my code? Or is it really not supported?