Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

This focus issue is a tough one

Guest
Jan 27, 2013 Jan 27, 2013

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

TOPICS
ActionScript
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 27, 2013 Jan 27, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2013 Jan 27, 2013

what line of code is triggering the null error?  (click file>publish settings>swf and tick "permit debugging")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2013 Jan 27, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2013 Jan 27, 2013

can you click file>publish settings>swf and tick "permit debugging"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2013 Jan 27, 2013

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2013 Jan 27, 2013

don't bother with break points or using the debugger.  you can debug all flash problems using the trace function and enabling debugging.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2013 Jan 28, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 28, 2013 Jan 28, 2013

Make sure you still have a TextInput component and all of its assets in your library.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2013 Jan 28, 2013

Yep - it's in there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2013 Jan 28, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

post a link to your zipped/rar'd files.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 29, 2013 Jan 29, 2013

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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

these are the problem:

data_grid.focusEnabled = false;

data_grid.mouseFocusEnabled = false;  

what's the purpose of those two lines?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 29, 2013 Jan 29, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

enable those properties only when ctrl or shift are pressed.  otherwise, disable them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 04, 2013 Feb 04, 2013

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; }

        }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 04, 2013 Feb 04, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 23, 2016 Aug 23, 2016
LATEST

I solve with below.

this.stage.focus = myDatagrid;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines