Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
jones74 #1
checking for null
Hello
Im a action scripting newbie please help.
I am using the following script to pass a color to a layer from the qstring,
this works ok as long as I pass a color, i am trying to check if it is null
then populate it with the default color but it does not work
================================================
onClipEvent (load)
{
myColor = new Color(this);
if(_root.GS6color =null)
{
myColor.setRGB ("0x399880");
}
if(_root.GS6color!="")
{
myColor.setRGB (_root.GS6color);
}
}
===============================================
Any help appreciated
Chris
jones74 Guest
-
NULL NULL Error
I have run out of things to check for and could use some help. We are on a unix box, CFMX 7, and have started to use the CFDOCUMENT tag. The tag... -
"null null" error on line -1
Hi, A different, new, ocasional error this time. Since we are using CFMX7, occasionally we get this error: " Application Exception Monitor... -
Error checking - Empty and Null and 0
Thanks this worked great... cfset math = Val(myvar) +1 -
Error: ?null? is null or not an object
eloine: That is a bogus error message in that it probably refers to something you have done (or not done) on the page. So, looking in the... -
How to ensure if column A is null, column B has to be null
Thank you Delbert! -
UsualSuspect #2
Re: checking for null
try it like this:
if(_root.GS6color ==null())
or like this:
if(_root.GS6color ==undefined)
UsualSuspect Guest
-
Pea #3
Re: checking for null
The best way is to use 3 equals signs. When you use 3 equals it matches not
only the value, but the type of the variable as well. For example, if you have
a boolean value like this:
var myBool = false;
if (myBool==false){ trace('false'); } // This will print 'false'
myBool = null;
if (myBool==false){ trace('false'); } // This will also print 'false'
But if you use === it works fine:
myBool = null;
if (myBool===false){ trace('false'); } // This will not print anything
if (myBool===null){ trace('null'); } // This will print 'null'
NOTE:
If you use just 1 equals sign, you are not checking whether it is null, but
actuall setting it to null.
if (a==b){ // do this }
the above checks if a's value is equal to b's value and does the 'do this'
code if its true
if (a=b){ // do this }
the above SETS a's value to b's value and then ALWAYS does 'do this'
if (a===b){ // do this }
the above checks if a's value is equal to b's value AND a's type is equalt to
b's type, and then does the 'do this' code if its true
Hope it helps,
Pea
Pea Guest
-
Pea #4
Re: checking for null
when reading aloud, read = as 'set to' and == as 'is equal to', === as 'is exactly equal to'
a=b (a set to b)
a==b (a is equal to b)
a===b (a is exactly equal to b)
Pea Guest



Reply With Quote

