PDA

View Full Version : hi jesse, true/false visible question


pbjpb
01-15-2002, 03:56 PM
hi jesse, quick question..in your ecard tut. you have the _x and _y variables for each attached MC load in the reader.swf like this:

xpos = Number(locationArray.shift());
ypos = Number(locationArray.shift());

what i'm trying to do is add the 'visible' property and i have the writer working corectly sending a 'true' or 'false' in the string but the reader is not displaying it right with either of these codes:

visible = Number(locationArray.shift());
OR
visible = locationArray.shift();

i know since it's a word being sent rather than a number it doesn't need to be converted to a number but i can't figure out what's wrong. any ideas? thanks!

tg
01-15-2002, 04:12 PM
"true" with quotes is a string value.
true with out quotes is a boolean value. if your are using the first, _visible willnot see that as a boolean value (true/false or 0/1). check if you are using a string or a bool. if that doesn't do it try eval().

pbjpb
01-15-2002, 05:42 PM
thanks tg! ok i am using a boolean, my string looks like this in the text file:

locationString=bas12,422,290,true

i tried eval but that doesn't work either...any other ideas? thanks!

tg
01-15-2002, 11:21 PM
ok, i'm assuming that you are using string.split to put your value into an array, my guess is that if you look at the variables in list variables, in test movie, it will look like this "true" (a string). if not then try changing your var to locationString=bas12,422,290,true&
the ampersand will trim off potential unseen characters.

Jesse
01-16-2002, 12:59 PM
Either:
- Use 1 and 0 instead of true and false, that way you can use Number()
- Use valueOf on the string:
myvar = "true";
trace(myVar.valueOf());
valueOf is a Boolean method.

pbjpb
01-18-2002, 03:19 PM
thanks guys this is how i fixed it..in the reader:

visible = (locationArray.shift() == "true") ? true : false;

that sets conditions and it works good :)