Re: [Flashcoders] cast string to a boolean value

2005-10-28 Thread Steve Mathews
Try:
var my_bool:Boolean = flashvar_bool==false?false:true;

The basic problem is creating a Boolean with any string makes it true.
So creating it with the string false still makes it true.

On 10/28/05, Matt Ganz [EMAIL PROTECTED] wrote:
 hi.

 i'm receiving FlashVars in my object and embed code and the values are
 either true or false. i assume they're brought into flash as
 strings and i need them as booleans.

 it is my understanding that boolean() won't do what i want because all
 it does is evaluate the expression inside the parantheses instead of
 converting the value to a boolean. i also read a very brief comment on
 livedocs that the appropriate way to do it is cast to a number first
 and then a boolean. but that doesn't make sense to me.

 anyone have any experience with this?

 thanks. -- matt.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] cast string to a boolean value

2005-10-28 Thread Ian Thomas
What's wrong with the following?

var my_bool:Boolean=(flashvar_bool==true);

Ian

On 10/28/05, Steve Mathews [EMAIL PROTECTED] wrote:

 Try:
 var my_bool:Boolean = flashvar_bool==false?false:true;

 The basic problem is creating a Boolean with any string makes it true.
 So creating it with the string false still makes it true.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] cast string to a boolean value

2005-10-28 Thread Matt Ganz
both methods work nicely.

thank you.

On 10/28/05, Ian Thomas [EMAIL PROTECTED] wrote:
 What's wrong with the following?

 var my_bool:Boolean=(flashvar_bool==true);

 Ian

 On 10/28/05, Steve Mathews [EMAIL PROTECTED] wrote:
 
  Try:
  var my_bool:Boolean = flashvar_bool==false?false:true;
 
  The basic problem is creating a Boolean with any string makes it true.
  So creating it with the string false still makes it true.
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] cast string to a boolean value

2005-10-28 Thread Cedric Muller

sorry about my previous example ;)

can't your receive 1 and 0 instead of true/false ?

this works:

var my_boolean_string:String = 1;
var my_boolean:Boolean = Boolean(Number(my_boolean_string));
if(my_boolean == true) {
trace(cool);
} else {
trace(nope);
}

Cedric


Try:
var my_bool:Boolean = flashvar_bool==false?false:true;

The basic problem is creating a Boolean with any string makes it true.
So creating it with the string false still makes it true.

On 10/28/05, Matt Ganz [EMAIL PROTECTED] wrote:

hi.

i'm receiving FlashVars in my object and embed code and the values are
either true or false. i assume they're brought into flash as
strings and i need them as booleans.

it is my understanding that boolean() won't do what i want because all
it does is evaluate the expression inside the parantheses instead of
converting the value to a boolean. i also read a very brief comment on
livedocs that the appropriate way to do it is cast to a number first
and then a boolean. but that doesn't make sense to me.

anyone have any experience with this?

thanks. -- matt.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders