Mike, Thanks... I should have checked the FAQ..RTFM Rob
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Chambers Sent: Friday, October 21, 2005 4:45 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Undefined and null in Flex2 What is the difference between null and undefined? http://labs.macromedia.com/wiki/index.php/ActionScript_3:resources:FAQ#What_ is_the_difference_between_null_and_undefined.3F -- In AS3, an undeclared var or property has a value of undefined. A declared var or property which has not been assigned a value has a default value of null. -- This is an alpha, so there are probably still some inconsistencies in the docs and APIs. mike chambers [EMAIL PROTECTED] Robert Edgar wrote: > Thanks spike for taking the time to reply but....... > > Calling it legacy seems to contradict the current AS3 docs.. > > For example I think it is getStyle that is documented to return > undefined if the style property doesn't not exist, it then goes on to > say that the "undefined" it returns is NOT the same as null > (undefined!=null). > > So I take from that that undefined far from being legacy is alive and > well and activley used by MM in AS3... > > Of course could be then docs are wrong or will change. > > I note the comment about how it only applies to Object though and > understand how when assigned the value will be coerced, thanks. > > It seemed to me that the docs were effectively setting a recommended > practice that for generic "getAnyProperty" type of functions they > should return undefined for undefined values rather than as at present > return null(because currently undefined==null). > > I am somewhat confused now if MM regard undefined as legacy i.e. > deprecated, should we being returning undefined or null. > > > Also given that undefined!=null makes me wonder.. > > if(!x){...}else{} > > Does this work differently in AS3 dependent on whether x is undefined > or null or does AS3 require explicit check for nullness "if(x!=null)" > > Rob > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Spike > Sent: Friday, October 21, 2005 5:42 AM > To: Flashcoders mailing list > Subject: Re: [Flashcoders] Undefined and null in Flex2 > > > Hi Robert, > > Gordon Smith from Macromedia posted this to another list a while ago. > I am reproducing it with his permission. Hopefully it will clarify > things a bit: > > Note, that this applies only to AS 3, not to AS 2 > > *************************************************************** > 'undefined' is basically legacy baggage in AS3 that must remain for > ECMA-262 compatibility. > > Type Object is the ONLY type that can store the value undefined. It > can also store the value null... it can store anything! > > Some but not all other classes can store null: > > A derived class like Button can store null but not undefined. > > String and Array can store null but not undefined. > > Number can store NaN but it can't store undefined or null. > > int and uint can't store NaN, undefined, or null; they only store > integers like 23. > > Boolean can't store undefined or null; it only stores true and false. > > Since Object is the only type that can store undefined, if you try to > set a var of another type to undefined, it will be coerced into > something different. For example, setting a Number to undefined will > coerce it to NaN. > > - Gordon > ********************************************************************* > > Spike > > > On 10/21/05, Robert Edgar <[EMAIL PROTECTED]> wrote: > >>AFAIK null and undefined are the same thing in F7/8 and can be used >>interchangeably Conceptually however we tend to think of 'undefined' >>and 'defined but has a >>null value' as two different things. >> >>>From what I have read in the Flex2 documentation undefined and null >> >>>are >> >>no >>longer the same thing and null means 'defined but has a null value'. >> >>Can someone confirm that is correct. >> >>Thanks >>Rob >> >> >>_______________________________________________ >>Flashcoders mailing list >>[email protected] >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> > > > > > -- > -------------------------------------------- > Stephen Milligan > Do you do the Badger? > http://www.yellowbadger.com > > Do you cfeclipse? http://www.cfeclipse.org > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

