Cool, glad that you figured it out.  No hard feelings.

-TH

--- In [email protected], "steve horvath" <flexcod...@...>
wrote:
>
>
> I figured it out. The problem was due to the fact that I had a bind
tag
> set on the ArrayCollection getter that is updated whenever a
> CollectionChange occurs.
>
> I will post a more complete question next time. Thanks to Tim and
Tracy
> for trying to help.
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute"
> applicationComplete="init()">
> <mx:Label id="label1" text="{albumsThumbnailList.selectedIndex}"
> x="10" y="12"/>
> <mx:Label id="label2" text="{presentedAlbumIndex}" x="10" y="38"/>
> <mx:TileList id="albumsThumbnailList" direction="vertical"
> dataProvider="{presentedAlbums}"
> selectedIndex="{presentedAlbumIndex}" x="160" y="10"
> change="presentedAlbumIndex=albumsThumbnailList.selectedIndex"
> height="400"/>
> <mx:Button click="test()" x="29" y="136"/>
>
> <mx:Script>
> <![CDATA[
> import mx.events.CollectionEvent;
> import mx.collections.ArrayCollection;
> private var _includedAlbums:ArrayCollection =
> new
>
ArrayCollection(["zero","one","two","three","four","five","six","seven"]\
\
> );
>
> [Bindable]
> private var presentedAlbumIndex:int = -1;
>
> private function init():void {
>
> _includedAlbums.addEventListener(CollectionEvent.COLLECTION_CHANGE,
> function():void {
> dispatchEvent(new Event("albumDataChanged"));
> }
> );
> }
>
> private function test():void {
> _includedAlbums.removeItemAt(1);
> presentedAlbumIndex--;
> }
>
> [Bindable(event="albumDataChanged")]
> private function get presentedAlbums():ArrayCollection {
> return _includedAlbums;
> }
>
> ]]>
> </mx:Script>
>
> </mx:Application>
>
>
> --- In [email protected], "steve horvath" flexcoders@
> wrote:
> >
> > My apologies. I really didn't mean to come across as brash. I
> realize you are trying to help and I do appreciate it.
> >
> > Let me put together a small app and I'll post it here.
> >
> > Steve
> >
> > --- In [email protected], "Tim Hoff" TimHoff@ wrote:
> > >
> > >
> > > Yes, _includedAlbums.selectedItem should have been
> > > albumsThumbnailList.selectedItem. And no, the code below is not
> > > sufficient to reproduce the problem. For instance, where is
> > > presentations.currentPresentation.presentedAlbumIndex defined? If
> you
> > > want someone's help here, make it easy for them to copy and paste
a
> > > small Application for testing.
> > >
> > > Besides that, excuse the hell out of me. Go ahead and continue to
> look
> > > at it for hours.
> > >
> > > -TH
> > >
> > > --- In [email protected], "steve horvath" <flexcoders@>
> > > wrote:
> > > >
> > > >
> > > > The code below is sufficient to reproduce the problem.
> > > >
> > > > _includedAlbums is an ArrayCollection, so no .selectedItem
> property on
> > > > that. In any case, I am already happily setting the
> > > presentedAlbumIndex
> > > > by other means. It's the TileList selectedIndex that I need to
> update
> > > > properly.
> > > >
> > > > --- In [email protected], "Tim Hoff" TimHoff@ wrote:
> > > > >
> > > > >
> > > > > Not sure what to tell you without having a sample application
to
> > > play
> > > > > with. But, you could try some brute force techniques, like:
> > > > >
> > > > > _includedAlbums.removeItemAt(1);
> > > > > presentations.currentPresentation.presentedAlbumIndex =
> > > > > _includedAlbums.getItemIndex(_includedAlbums.selectedItem);
> > > > >
> > > > > -TH
> > > > >
> > > > > --- In [email protected], "steve horvath" flexcoders@
> > > > > wrote:
> > > > > >
> > > > > >
> > > > > > I've been looking at this for hours. Does anyone know why I
am
> > > > seeing
> > > > > > this behavior? Or at least tell me how I can debug to
provide
> more
> > > > > > information.
> > > > > >
> > > > > >
> > > > > > --- In [email protected], "steve horvath"
flexcoders@
> > > > > > wrote:
> > > > > > >
> > > > > > >
> > > > > > > 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