Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
Developer
p3pp3r
Posts: 156
Registered: 12-16-2010
My Carrier: I carry it myself
Accepted Solution

List throwing "Cannot access a property or method of a null object reference." when scrolling white space

Do this:

 

	import flash.display.Sprite;
	
	import qnx.fuse.ui.listClasses.List;
	import qnx.ui.data.DataProvider;
	
	[SWF(height="1024", width="600", frameRate="30", BackgroundColor="#000000")]
	public class test3 extends Sprite
	{
		public function test3()
		{
			var l:List = new List();
			l.dataProvider = new DataProvider([{label:1},{label:2}]);
			l.setPosition(200,200);
			l.width = 200;
			l.height = 200;
			addChild(l);
		}
	}

And run the application.

 

Point the finger right below the last row in the list and swipe up or down.

 

You get this:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at qnx.fuse.ui.listClasses::List/resetCellState()[E:\hudson\workspace\GR2_0_0_AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\listClasses\List.as:2532]
	at qnx.fuse.ui.listClasses::List/deselectCellDown()[E:\hudson\workspace\GR2_0_0_AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\listClasses\List.as:2337]
	at qnx.fuse.ui.listClasses::List/scrollMouseMove()[E:\hudson\workspace\GR2_0_0_AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\listClasses\List.as:2349]

 How do I trap this? Is this a bug of the qnx.fuse.up.listClasses.List component?

 

----------
If you find this post helpful please "like" it and accept as a solution.
Please use plain text.
Developer
p3pp3r
Posts: 156
Registered: 12-16-2010
My Carrier: I carry it myself

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

After typing this post I went back to SDK download page and noticed there is a new 2.0.0 SDK available (dated February 3rd, 2012). I was using previous SDK version dated January 16th , 2012. 

 

So I went ahead and upgraded to the latest SDK and this error no longer occurs!

 

It must have been a bug.

 

So I (sort of) solved my own problem.. Kudos to me... ha!

----------
If you find this post helpful please "like" it and accept as a solution.
Please use plain text.
New Contributor
Mike_Graves
Posts: 7
Registered: 02-21-2012
My Carrier: Developer

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

@P3pp3r,

I am running into the same issue over here I thought it might be on the custom renderer that I created but I am still running into this issue.

I see the issue once its adding the Playbook. I do have the latest SDK. I have zero clue.

var colors:Array=[];
			// add objects with a label property
			var total:Number = Colors.DEFAULT.length;
			for(var i:Number=0;i<total;i++) {
				colors[i] = {color:Colors.DEFAULT[i]};
			}
			
			var myList:List = new List();            
			myList.setPosition(0, 0);            
			myList.width = 269;            
			myList.height = 70;
			myList.columnWidth = 60;
			
			//set the dataProvider
			myList.scrollDirection = ScrollDirection.HORIZONTAL;
			myList.dataProvider = new DataProvider(colors);
			myList.cellRenderer = MyCustomCellRenderer;
			
			myList.addEventListener(ListEvent.ITEM_CLICKED, onListClick);
			myList.addEventListener(ScrollEvent.SCROLL_END, onScroll);
			myList.addEventListener(ScrollEvent.SCROLL_BEGIN, onScrollStart);
			
			this.addChild(myList);

and Renderer:

package renderers {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	
	import qnx.fuse.ui.listClasses.AlternatingCellRenderer;
	import qnx.fuse.ui.listClasses.CellRenderer;
	import qnx.ui.buttons.CheckBox;
	
	public class MyCustomCellRenderer extends CellRenderer  {
		public var ct:ColorTransform;
		public function MyCustomCellRenderer() {
			ct = new ColorTransform();
		}
		
		override protected function init():void {
			super.init();
		}
		
		override public function set data(value:Object):void {
			super.data = value;
			if (value != null) {
				ct.color = this.data.color
				this.transform.colorTransform = ct;	
			}
			super.invalidateDisplayList();
		}
		
		//this will prevent the cell from being selected when the button is clicked down
		private function onMouseDown(event:MouseEvent):void {
			event.stopImmediatePropagation();
		}
		
		private function onClick(event:MouseEvent):void {
			dispatchEvent( new Event( Event.SELECT, true, true ) );
		}
	}
}

 


Please use plain text.
Developer
jtegen
Posts: 4,247
Registered: 10-27-2010
My Carrier: Verizon

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

Does the error go away if you comment out the set renderer line?
Please use plain text.
New Contributor
Mike_Graves
Posts: 7
Registered: 02-21-2012
My Carrier: Developer

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

I tried it and it still crashes.
Please use plain text.
Developer
jtegen
Posts: 4,247
Registered: 10-27-2010
My Carrier: Verizon

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

Might seem odd but try:

 

for(var i:int=0;i<total;i++)

{
colors[i] = {data:Colors.DEFAULT[i], label : 'color ' + String( i ) };
}

Please use plain text.
New Contributor
Mike_Graves
Posts: 7
Registered: 02-21-2012
My Carrier: Developer

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

Same error....The thing is that I just added that label prop to the colors array just for testing. You can still get the crush without the custom renderer. Seems to me like thats a big bug with the list component. Also the list also becomes non responsive at times on the device if the user is "flicking" fast (but without a crash).
Please use plain text.
Developer
p3pp3r
Posts: 156
Registered: 12-16-2010
My Carrier: I carry it myself

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

Are you sure your project path points to release sdk and not to beta libraries? This is exact behaviour I was experiencing in beta which was resolved in final.
----------
If you find this post helpful please "like" it and accept as a solution.
Please use plain text.
New Contributor
Mike_Graves
Posts: 7
Registered: 02-21-2012
My Carrier: Developer

Re: List throwing "Cannot access a property or method of a null object reference." when scrolling white space

lol, yes I am 100% sure that I am using the correct SDK. I downloaded it from here. https://bdsc.webapps.blackberry.com/air/download/sdk
I would hope this wasn't a beta SDK.
Please use plain text.