- Home /
'text' is not a member of 'OBJECT' JavaScript Not Working in Unity 3.5 - Lost Commands?
Hi, I've taken an older project and inserted it into Unity 3.5 (from 3.4), and it appears that many of the commands for checking web content No Longer Work...? I keep getting "'text' is not a member of 'OBJECT'" or "'error' is not a member of 'OBJECT'", etc...
There are over 200 errors - so here is just one example... of the .TEXT and .ERROR Not Working...
CAN YOU TELL ME WHAT THE NEW VERSIONS OF THESE ARE OR WHAT I SHOULD PUT:
Example using: .TEXT .ERROR
(The earlier part of this script loads a button graphic... then this script load the link the button should visit - hence its waiting to get back the .text from the WWWeb - of the link for the button - so when the user presses the button - it visits the correct web page)
function checkforbuttonlink0() {
linkb0 = "http://mywebsite.com/sendsback-a-buttons-weblink--script.php?buttonnumber="+button+"&id="+for-account;
// Check if it exists
link0_b = WWW(linkb0);
// Wait/Load
yield link0_b;
linkimb0 = (link0_b.text);
yield linkimb0;
// Error check
if (link0_b.error){
TextHints.message = "ERROR (CHECK INTERNET CONNECTION)";
TextHints.textOn = true;
eerr0 = 1;
//Dont Instantiate
}
if (linkimb0 == ""){
eerr0 = 1;
//Dont Instantiate
//nothin
}
if (linkimb0.length > 100){
eerr0 = 1;
//Dont Instantiate
//nothin
}
////print"eerr0 is:"+eerr0);
if (eerr0 == 0) {
//////print"NEW - I found >>"+linkimb+"<< so I loaded a button - eerr is:"+eerr);
if (linkimb0 != "error"){
buttonstore.load0 = linkimb0;
}
}
}
NOTE : Having the same problem with the .length javascript Command - "..is not a member of 'OBJECT'"
Stil having troubles in some areas...
Could you give me a snippet/ example from my text above as to the correct way?
Especially:
linkimb0 = (link0_b.text);
yield linkimb0;
// Error check
if (link0_b.error){
TextHints.message = "ERROR (CHEC$$anonymous$$ INTERNET CONNECTION)";
TextHints.textOn = true;
eerr0 = 1;
//Dont Instantiate
}
if (linkimb0 == ""){
eerr0 = 1;
//Dont Instantiate
//nothin
}
$$anonymous$$uch appreciated...
$$anonymous$$
Also... if it wasn't clear - my apologies.. at the start of the script above - I declared all variables similar to this ($$anonymous$$us any #pragma... commands):
var linkimb0; var link0_b; var eerr0 : int;
...etc. $$anonymous$$
Yes, as per Eric's answer, it's pretty obvous from the error you're getting that you haven't declared the types of all your variables. We already know what the problem is- all you need to do is manually declare the types of all your variables, not just some of them!
Answer by Eric5h5 · Mar 09, 2012 at 03:05 PM
There are no missing commands; "not a member of Object" means you're trying to use dynamic typing with #pragma strict, which is not allowed. So remove all dynamic typing.
Exactly, the 3.5 compiler is simply a little more strict by default. either type your objects correctly or add the #pragma implicit/#pragma downcast - I forget which.
No, the compiler isn't any more strict, it's just that JS script templates include #pragma strict by default in 3.5. This can be removed if desired (but probably shouldn't be in most cases). Also, adding #pragma implicit/downcast will not remove the "no dynamic typing" rule of #pragma strict. #pragma implicit allows variables to be declared without "var", and the only thing #pragma downcast does is remove the warning if you downcast, it doesn't actually change anything.
Right, I hate to debate against 53k of knowledge, hehe. I agree about the #pragma strict - which makes the compiler more strict, yet I'm pretty sure that when I was using JS and #strict, I've had to use the #downcast to compensate for that exact situation (IE: inspector's enum) but my memory might be playing tricks on me, sorry.
Answer by djkr · Mar 13, 2012 at 04:25 AM
Awesome... It's starting to work... very simply just declaring my var TYPE first... OK... This is great!
Thanks very much!!!!! You guys are amazing!
For anyone reading - THE ANSWER WAS basiially:
DO THIS (AFTER...But you first need to tell it what the variable will be [var x : String, Int, WWW, etc] )
linkb0 = "http://mywebsite.com/sendsback-a-buttons-weblink--script.php?buttonnumber="+button+"&id="+for-account;
// Check if it exists
link0_b = WWW(linkb0);
// Wait/Load
yield link0_b;
linkimb0 = (link0_b.text);
yield linkimb0;
YOU MUST FIRST STATE THIS AT THE TOP:
var linkb0 : WWW;
var link0_b : WWW;
var linkimb0 : String;
..very simple...LoLz... Thanks Again...! K
Your answer
Follow this Question
Related Questions
Disable GameObject Only Father Not Children 2 Answers
Setting a variable to an instantiated object. 1 Answer
touch 3d object open gui 1 Answer
Drawing a 3D object javascipt 0 Answers
Object won't collide with Player unless Player is moving 1 Answer