Re: [flexcoders] Cannot access a property or method of a null object reference?

2008-06-09 Thread Michael Schmalle
Hi,

From the look if it

;ComboBox(event.target).selectedItem

seems to be where the null pointer is. Make sure you actually have a
selectedItem in the list.

I have actually done this myself when testing and actually forgot to
'select' an item before a service call.

Mike

On Mon, Jun 9, 2008 at 6:52 AM, xaero [EMAIL PROTECTED] wrote:

   Hi
 I'my working whit flex and amfphp.
 In my exercise, the flex debug say this error:

 TypeError: Error #1009: Cannot access a property or method of a null object
 reference.
 at cys/changeHandler()[D:\My
 Documents\FlexBuilder3\cys\src\cys.mxml:51]
 at cys/__atclass_close()[D:\My
 Documents\FlexBuilder3\cys\src\cys.mxml:70]

 line around 51:

 public function changeHandler(event:Event):void
 {
 var atClass:Object = new Object;
 atClass.atcls = ComboBox(event.target).selectedItem.data;

 gateway.call(Cys.getStudents, new Responder(getResult,
 onFault), atClass); // this is line 51
 }

 getResult is another function that give the result to ComboBox's
 dataProvider:
 public function getResult(result:Array):void
 {
 ssProvider = result;
 }

 onFault:
 public function onFault(fault:String ):void
 {
 trace(fault);
 }

 line 70:
 mx:ComboBox y=202 id=atclass close=changeHandler(event);
 dataProvider={atClassProvider} fontSize=12 x=40/mx:ComboBox
 this comboBox can display properly.

 Cys is a Class, it is under amfphp/services  and its file code:
 ?php
 Define('DATABASE_SERVER', 'localhost');
 Define('DATABASE_USERNAME', 'root');
 Define('DATABASE_PASSWORD', '123456');
 Define('DATABASE_NAME', 'cys');

 class Cys
 {
 var $mysqli;

 function Cys()
 {
 # Connect to MySQL database
 $this-mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME,
 DATABASE_PASSWORD, DATABASE_NAME);
 # Check MySQL connection
 if (mysqli_connect_errno()) {
 # Dont use die (Fatal Error), return useful info to the client
 trigger_error(AMFPHP Remoting class could not connect:  .
 mysqli_connect_error());
 }
 }
 function getStudents($atClass) {
 # Return a list of all the users
 $atcls =
 $this-mysqli-real_escape_string(trim($atClass['atcls']));
 $sql = SELECT * from students where atclass = '.$atcls.';
 if ([EMAIL PROTECTED]mysqli-query($sql)) {
 $errno=$this-mysqli-errno;
 $this-mysqli-close();
 trigger_error(AMFPHP Remoting class database SELECT query
 error:  . $errno);
 }
 while ($row = $result-fetch_assoc()) {
 $user_array[] = $row;
 }
 return($user_array);
 }
 }
 ?
  




-- 
Teoti Graphix, LLC
http://www.teotigraphix.com

Teoti Graphix Blog
http://www.blog.teotigraphix.com

You can find more by solving the problem then by 'asking the question'.


RE: [flexcoders] Cannot access a property or method of a null object reference

2008-01-02 Thread Gordon Smith
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Christophe Herreman
Sent: Tuesday, January 01, 2008 12:15 PM
To: flexcoders@yahoogroups.com
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  

 


Re: [flexcoders] Cannot access a property or method of a null object reference

2008-01-01 Thread Christophe Herreman
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.pranaframework.com

2008/1/1, [EMAIL PROTECTED] [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;
 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.pranaframework.org


Re: [flexcoders] Cannot access a property or method of a null object reference

2008-01-01 Thread [EMAIL PROTECTED]
Thanks, that was it.

Christophe Herreman wrote:

 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
  



Re: [flexcoders] Cannot access a property or method of a null object reference

2008-01-01 Thread fmotagarcia
you forgot to instantiate the object.

Change:
var test:testClass;
to
var test:testClass = new testClass();

and it should work.

Regards,

Frederico Garcia

On Tue, 01 Jan 2008 14:45:00 -0500, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 
 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;
 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);
 }
 }
 
 }
 
 
 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links
 
 
 


RE: [flexcoders] Cannot access a property or method of a null object reference

2007-01-27 Thread Tracy Spratt
I bet that is correct.  I have found that it is best to use callLater
for any control manipulation if I have just modified the dataProvider.

 

But, Roger, don't guess.  Debug the code to find out which line is
producing the error.  If you don't have good debugging techniques,
develop them now.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Clint Tredway
Sent: Thursday, January 25, 2007 12:07 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Cannot access a property or method of a null
object reference

 

most likely the setting of the selectedIndex is what is causing that
error. Its trying to set a property to a component that doesnt exist
yet.

On 1/25/07, Roger Ross [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Hello,

Working my way throught the Training From the Source turorial and
ran into this error message.

Not sure why I am getting it. I compared my code to the completed code
for the lesson and it looks the same with no problems when I compile it.

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at Dashboard/::catHandler()
at Dashboard/__catRPC_result()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven
tFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal
::dispatchRpcEvent
http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent ()
at
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resu
ltHandler http://www.adobe.com/2006/flex/mx/internal::resultHandler ()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::DirectHTTPMessageResponder/completeHandler()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven
tFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

Here is a copy of the code that it has me write with the comboBox that
is to receive the data:


?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
http://www.adobe.com/2006/mxml 
layout=horizontal
creationComplete=catRPC.send()

mx:Script
![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var categories:ArrayCollection=new ArrayCollection();

private function catHandler(event:ResultEvent):void{
categories = event.result.catelog.category;
var catObj:Object = new Object();
catObj.name = All;
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}

]]
/mx:Script

mx:HTTPService id=catRPC
url=http://www.flexgrocer.com/category.xml
http://www.flexgrocer.com/category.xml 
result=catHandler(event)/

mx:ComboBox id=catCombo
dataProvider={categories}
labelField=name/

Any Idea's...

Thanks,

Roger




-- 
http://indeegrumpee.spaces.live.com/
http://indeegrumpee.spaces.live.com/  

 



Re: [flexcoders] Cannot access a property or method of a null object reference

2007-01-25 Thread Doug McCune

Is catalog misspelled?

categories = event.result.catelog.category;

If there's no catelog child of the XML root, then trying to access a 
child of that node will probably throw the error.


Doug

Roger Ross wrote:


Hello,

Working my way throught the Training From the Source turorial and
ran into this error message.

Not sure why I am getting it. I compared my code to the completed code
for the lesson and it looks the same with no problems when I compile it.

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at Dashboard/::catHandler()
at Dashboard/__catRPC_result()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent 
http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()

at
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler 
http://www.adobe.com/2006/flex/mx/internal::resultHandler()

at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::DirectHTTPMessageResponder/completeHandler()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

Here is a copy of the code that it has me write with the comboBox that
is to receive the data:


?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml 
http://www.adobe.com/2006/mxml

layout=horizontal
creationComplete=catRPC.send()

mx:Script
![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var categories:ArrayCollection=new ArrayCollection();

private function catHandler(event:ResultEvent):void{
categories = event.result.catelog.category;
var catObj:Object = new Object();
catObj.name = All;
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}

]]
/mx:Script

mx:HTTPService id=catRPC
url=http://www.flexgrocer.com/category.xml 
http://www.flexgrocer.com/category.xml

result=catHandler(event)/

mx:ComboBox id=catCombo
dataProvider={categories}
labelField=name/

Any Idea's...

Thanks,

Roger

 




Re: [flexcoders] Cannot access a property or method of a null object reference

2007-01-25 Thread Clint Tredway

most likely the setting of the selectedIndex is what is causing that error.
Its trying to set a property to a component that doesnt exist yet.

On 1/25/07, Roger Ross [EMAIL PROTECTED] wrote:


  Hello,

Working my way throught the Training From the Source turorial and
ran into this error message.

Not sure why I am getting it. I compared my code to the completed code
for the lesson and it looks the same with no problems when I compile it.

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at Dashboard/::catHandler()
at Dashboard/__catRPC_result()
at

flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction
()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.rpc.http.mxml::HTTPService/
http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at
mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::DirectHTTPMessageResponder/completeHandler()
at

flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction
()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

Here is a copy of the code that it has me write with the comboBox that
is to receive the data:


?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=horizontal
creationComplete=catRPC.send()

mx:Script
![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var categories:ArrayCollection=new ArrayCollection();

private function catHandler(event:ResultEvent):void{
categories = event.result.catelog.category;
var catObj:Object = new Object();
catObj.name = All;
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}

]]
/mx:Script

mx:HTTPService id=catRPC
url=http://www.flexgrocer.com/category.xml;
result=catHandler(event)/

mx:ComboBox id=catCombo
dataProvider={categories}
labelField=name/

Any Idea's…

Thanks,

Roger

 





--
http://indeegrumpee.spaces.live.com/