Copy link to clipboard
Copied
Gidday guys
This one has been bugging me all day.
If I select a row in my datagrid, then click out of my AIR desktop app to another program, desktop etc, then click back into the AIR app, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::TextInput/setFocus()
at fl.managers::FocusManager/activateHandler()
I set up the following to deselect the row, but the error still occurs:
data_grid.addEventListener(Event.DEACTIVATE, deselectRow, false, 0, true);
private function deselectRow(event:Event):void
{
data_grid.selectedIndex = null;
}
Anyone had this happen before and know of a fix?
Cheers
Copy link to clipboard
Copied
Normally a non-selection for a list is assigned -1, not null. I don't know if that is part of your problem or not.
Copy link to clipboard
Copied
what line of code is triggering the null error? (click file>publish settings>swf and tick "permit debugging")
Copy link to clipboard
Copied
That's strange - it's not happening anymore. I'll try and re-create the erro.
kGlad - I'm yet to set up debugging for CS6 - since I upgraded, the debugger doesn't work.
Thanks guys
Copy link to clipboard
Copied
can you click file>publish settings>swf and tick "permit debugging"?
Copy link to clipboard
Copied
Yeah, which was resulting in the debugger starting, but nothing compiling, but it actually, it might be working now - it's giving me a
Breakpoint not set; No executable code at line 4279 of Scene 1, Layer 'as3', Frame 1
although that line is just...
var book2:String;
Copy link to clipboard
Copied
don't bother with break points or using the debugger. you can debug all flash problems using the trace function and enabling debugging.
Copy link to clipboard
Copied
This bug still isn't revealing itself.
I've found a way to consistently replicate it:
1. click in an editable column - the text in it highlights
2. don't change anything - just click anywhere outside of the row
3. click outside of the AIR app so that it minimises
4. re-open the AIR app
5. the error occurs (no line number):
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::TextInput/setFocus()
at fl.managers::FocusManager/activateHandler()
I've set trace points at the end of all the functions that are called by any involved event listeners. All the points trace, and then the error occurs, so there seems to be nothing in my code that is directly triggering it.
I've noticed that if I do steps 1 and 2, an then click another editable row and this time edit the text in it, the error doesn't occur when I minimise/maximise.
Anything in there sticking out to anyone?
Copy link to clipboard
Copied
Make sure you still have a TextInput component and all of its assets in your library.
Copy link to clipboard
Copied
Yep - it's in there.
Copy link to clipboard
Copied
Ned - I've made a 50 line inline AS3 AIR file of just my datagrid and provider, and am able to replicate the problem using that ultra cut down version (I even have the event listeners turned off).
Would you be willing to take a look at it if I sent you the fla file?
Copy link to clipboard
Copied
post a link to your zipped/rar'd files.
Copy link to clipboard
Copied
Thanks for taking the time to have a look guys:
http://www.billygoatkaraoke.com.au/removeDupsTest2.zip
How to replicate
- compile
- in the Title column, click the top 'testy'
- click in the bottom part of the datagrid, below the three rows
- minimize the swf to the taskbar
- maximise swf to see it again
- error pops up in output display:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::TextInput/setFocus()
at fl.managers::FocusManager/activateHandler()
Copy link to clipboard
Copied
these are the problem:
data_grid.focusEnabled = false;
data_grid.mouseFocusEnabled = false;
what's the purpose of those two lines?
Copy link to clipboard
Copied
Cheers Keith - that's a big help towards solving this.
The purpose of those two lines was to solve a previous problem I was having re my Ctrl and Shift listeners not working correctly when the datagrid was selected - here's the forum conversation - http://forums.adobe.com/message/5019564#5019564
Setting...
data_grid.focusEnabled = false;
data_grid.mouseFocusEnabled = false;
...solved that problem (which allows me to perform certain edits on the datagrid ONLY when Ctrl or Shift are NOT pressed) , but is now presenting this new problem.
Copy link to clipboard
Copied
enable those properties only when ctrl or shift are pressed. otherwise, disable them.
Copy link to clipboard
Copied
Thanks Keith, but no go. It stops the error, but if I select a row in the datagrid, the KeyboardEvent.KEY_DOWN stage listener for onKeyBoardDown no longer gets triggered (same as original problem)...
//if ctrl (17) or shift key (16) is released
private function onKeyBoardUp(event:KeyboardEvent):void
{
if ( event.keyCode == 17 ) {ctrlIsDown = false; trace("CTRL released"); data_grid.focusEnabled = true; data_grid.mouseFocusEnabled = true; }
if ( event.keyCode == 16 ) {shiftIsDown = false; trace("SHIFT released"); data_grid.focusEnabled = true; data_grid.mouseFocusEnabled = true;}
}
//if ctrl (17) or shift key (16) is pressed
private function onKeyBoardDown(event:KeyboardEvent):void
{
if ( event.keyCode == 17 ) {ctrlIsDown = true; trace ("CTRL pressed"+ctrlIsDown); data_grid.focusEnabled = false; data_grid.mouseFocusEnabled = false; }
if ( event.keyCode == 16 ) {shiftIsDown = true; trace ("SHIFT pressed"+shiftIsDown); data_grid.focusEnabled = false; data_grid.mouseFocusEnabled = false; }
}
Copy link to clipboard
Copied
OK - I think I've got around it...
I've left in...
data_grid.focusEnabled = false;
data_grid.mouseFocusEnabled = false;
... in the set up for the data grid, so the shift and ctrl pressed functions work correctly.
I've added...
stage.addEventListener(Event.DEACTIVATE, displayDeactivated, false, 0, true);
private function displayDeactivated(event:Event):void { stage.focus = stage; }
...so that the focus is completely taken away from the datagrid if someone minimizes or clicks out of the app. Clicking back in the app no longer throws the error.
Copy link to clipboard
Copied
I solve with below.
this.stage.focus = myDatagrid;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now