If you asked me to evaluate my knowledge of Flex / ActionScript I am not sure what I would say. I don't use them enough to say either way but I think at this point I understand programming enough to get around any language. RocketFM is my file manager application that I started a couple months ago and has turned into a great project. I found a strange bug and It was nothing I have seen before so I was not quite sure where to begin. First let's take a look at the issue and then we can walk through the path to the answer.
If you take a look at the video below you can see the bug. When you open a folder pay attention to the number and then watch as I scroll all the way down and then all the way back up. When you get back to the top the wrong folder is open / selected.
Now we know the problem let's take a look at how I came to find a solution. The first thought is there is something going on with the tree and more specifically when you scroll. Taking a look at the Tree class we see the Inheritance list looks like this. It goes a little further but we will stop it right there.
Tree > List > ListBase > ScrollControlBase > UIComponent > FlexSprite > SpriteI took a look at the ScrollControlBase class and sure enough there is scroll event. This means that we can listen for a scroll event right on our tree. To do that we simply add a new event listener. In our onTreeScroll method we need to update the tree. Using the 2 methods below we are basically refreshing the tree every time the user scrolls. The bug is not that the data changes when you scroll, the problem is the tree just needs to be refreshed and this accomplishes it.
