Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. "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...
    3. Error checking - Empty and Null and 0
      Thanks this worked great... cfset math = Val(myvar) +1
    4. 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...
  3. #2

    Default Re: checking for null

    try it like this:

    if(_root.GS6color ==null())

    or like this:

    if(_root.GS6color ==undefined)
    UsualSuspect Guest

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139