That's because when you simply declare
 
    var test:testClass;
 
the variable 'test' is automatically assigned a default value of null.
 
The default value of a var depends on its type, as follows:
 
    Boolean --> false
    int/uint --> 0
    Number --> NaN
    Object --> undefined
    All other types --> null
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Christophe Herreman
Sent: Tuesday, January 01, 2008 12:15 PM
To: [email protected]
Subject: Re: [flexcoders] Cannot access a property or method of a null
object reference



Hi,

you need to create an instance of the testClass like this

var test:testClass = new testClass();

regards,
Christophe

--
Christophe Herreman
http://www.herrodius.com <http://www.herrodius.com> 
http://www.pranaframework.com <http://www.pranaframework.com> 


2008/1/1, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >: 

        
        This compiles but when you hit the test button, it says
        
        TypeError: Error #1009: Cannot access a property or method of a
null 
        object reference.
        at Main/test()
        at Main/__b1_click()
        
        Can anyone explain what this means ? It totally does not make
any sense 
        to me.
        
        >>>>>>main.mxml:
        <?xml version="1.0"?>
        
        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">
        <mx:Script source="MainCode.as"/>
        <mx:Button id="b1" label="Test" click="test();"/>
        
        </mx:Application>
        
        >>>>>>MainCode.as:
        Public function test():void
        { 
        var test:testClass;
        test.justtesting();
        
        }
        
        >>>>>>testClass.as:
        package {
        public class testClass {
        public function testClass() {
        
        }
        public function justtesting():void {
        trace("just testing");
        }
        }
        
        }
        

        




-- 
Christophe Herreman
http://www.herrodius.com <http://www.herrodius.com> 
http://www.pranaframework.org <http://www.pranaframework.org>  

 

Reply via email to