2

In my application I have a list of items which can be changed either by clicking on the list, using a next/previous button or via a menu which allows them to jump between items (mainly for the phone version which doesn't display the list).

I'm using the ensureIndexIsVisible function after the data provider for the list has been populated. However sometimes when I return to this page the application crashes out with the following error:

RangeError: Error #1125: The index 0 is out of range 0.
at spark.layouts.supportClasses::LinearLayoutVector/getMajorSize()[E:\dev\4.y\frameworks\projects\spark\src\spark\layouts\supportClasses\LinearLayoutVector.as:420]

The strange thing is that the index I pass into the function when it crashes isn't 0. It can be 1 or 3 or presumably anything. I can stop the application from crashing if I remove the function call but I need the list to show what question is currently selected.

The actual line that crashes is this: var block:Block = blockTable[index >> BLOCK_SHIFT]; from a function called getMajorSize

ketan
  • 19,129
  • 42
  • 60
  • 98
Rjs37
  • 189
  • 1
  • 13

2 Answers2

1

As this has gone unanswered for so long I thought I'd answer it myself back with what I've recently ended up doing.

I managed to get this issue resolved by mainly changing the points where I called the function. i.e. it was being called too early.

However I recently changed over to using a custom function that someone else posted as I found that the ensureIndexIsVisible was often jumping to the wrong position in the list (due to a variety in heights of the items).

The function can be found on this question and is called scrollToIndex: Scroll to selected item in Flex 4 Spark List component

Community
  • 1
  • 1
Rjs37
  • 189
  • 1
  • 13
  • ... But when did you end up calling it to make it work? I mean damn, it would be nice to have some event that would be fired once all layout has been done. Is it something obvious that I've just missed? – DuneCat Apr 23 '14 at 15:50
0

This error is related to FLEX-28291, which should be fixed in the next version of Apache Flex (probably 4.14).

user166267
  • 51
  • 1
  • 7