Copy link to clipboard
Copied
Hello,
Working on a site that uses flashVars. I was able to work with number variables no problem, but I have a boolean value that is proving to be more tricky than I anticipated. Any help would be appreciated!
the HTML Param is "isMetal"
I've tried a few things and this is what I have now...
var isMetal:Boolean;
function init():void
{
// true if 'isMetal' is set to '1'; false otherwise
isMetal = loaderInfo.parameters.isMetal != "0";
}
Then I try to use the boolean to pick between filter settings and layer blend modes... unfortunately, it always uses what happens after "else."
if(isMetal != 0)
{
color = new AdjustColor();
color.brightness = 100;
color.contrast = 10;
color.hue = 0;
color.saturation = -100;
loadLogo.blendMode = BlendMode.SCREEN;
}
else
{
color = new AdjustColor();
color.brightness = 0;
color.contrast = 10;
color.hue = 0;
color.saturation = -100;
loadLogo.blendMode = BlendMode.MULTIPLY;
}
all flashVars are strings. use it as a string:
if(isMetal!="0")
{
etc
Copy link to clipboard
Copied
all flashVars are strings. use it as a string:
if(isMetal!="0")
{
etc
Copy link to clipboard
Copied
I was reading online that I had to recast the boolean and that is was a bad idea to pass "false". Long story short...I was over thinking!
Thanks for your help!
Copy link to clipboard
Copied
you're welcome.
you can pass "false" or "true". you just have to remember that it's a string and not a boolean:
var s:String = "true";
if(s=="true"){ // good
etc
if(s){ // not so good. when s="false" (or when s is anything other than an empty string, this resolves to true.
etc
and, you definitely don't want to try casting a string as a boolean because you probably won't like the results:
var s:String="false";
var b:Boolean=Boolean(s):
trace(b); // output: true. again, when evaluating a string for true or false, all non-empty strings resolve to true and the empty string ("") resolves to false.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now