I have a TileList:

<mx:Label id="label1" text="{albumsThumbnailList.selectedIndex}" />
<mx:Label id="label2"
text="{presentations.currentPresentation.presentedAlbumIndex}" />
<mx:TileList id="albumsThumbnailList" backgroundAlpha="0"
useRollOver="false" initialize="mySizeBinding(event);"
     dataProvider="{presentations.currentPresentation.presentedAlbums}"
     itemRenderer="PresentationAlbumRenderer"
    
selectedIndex="{presentations.currentPresentation.presentedAlbumIndex}"
     change="albumChangeHandler()" />

public function test():void {
     _includedAlbums.removeItemAt(1);
     dispatchEvent(new Event("albumToggledEvent"));
     presentedAlbumIndex--;
}

BEFORE test():
label1 == 5
label2 == 5

AFTER test():
label1 == 5
label2 == 4

Problem is, when the 5th index is currently selected and I delete an
item earlier in the list (like index 2), the data provider updates the
list.  But the selectedIndex doesn't get updated.  (See test()
function.)  I noticed when I comment out the removeItemAt line, the
index gets updated just fine.

How do I update the data provider and index in the same operation and
get the TileList to bind correctly?  Can I perhaps subclass TileList and
override a function?  Some other way?

I tried looking into the internals of ListBase, inspecting
selectedIndex, and generally browsing around at runtime.  I noticed that
selectedIndex does get set to 4 momentarily.  Then it gets set right
back to 5 again.  I'm guessing it may have to do with the
updateDisplayList or something like that.


Reply via email to