Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

flashVars Boolean

Community Beginner ,
Feb 28, 2013 Feb 28, 2013

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;

}

TOPICS
ActionScript
712
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 28, 2013 Feb 28, 2013

all flashVars are strings.  use it as a string:

if(isMetal!="0")

{

etc

Translate
Community Expert ,
Feb 28, 2013 Feb 28, 2013

all flashVars are strings.  use it as a string:

if(isMetal!="0")

{

etc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 28, 2013 Feb 28, 2013

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2013 Mar 01, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines