Amy I just moved the changePolicy event for createComponentsfromDescriptors() to the resultHandler of the Photoservice, set the creationPolicy on Viewstack to none and it works like a charm.. thanks for putting me on the right track. I anyone else wants to use the Carousel as the only child of the Viewstack for this (very cool) app I hope they find this trick useful.
CS --- In [email protected], "cjsteury2" <cra...@...> wrote: > > Hi Again Amy, > Realizing that wasn't right I am now just getting a blank screen .. I am > still working on it so I'll keep you posted. > > package samples.photoviewer > { > import flash.events.*; > > import mx.collections.ArrayCollection; > import mx.collections.IViewCursor; > import mx.events.CollectionEvent; > import mx.rpc.events.ResultEvent; > import mx.rpc.http.HTTPService; > import mx.utils.ArrayUtil; > > public class PhotoService > { > private var service:HTTPService; > public var app:PhotoViewer; > > [Bindable] > public var galleries:ArrayCollection; > > public function PhotoService(url:String) > { > service = new HTTPService(); > service.url = url; > service.addEventListener(ResultEvent.RESULT, > resultHandler); > service.send(); > galleries = new ArrayCollection([]); > > galleries.addEventListener(CollectionEvent.COLLECTION_CHANGE, changePolicy); > } > > private function resultHandler(event:ResultEvent):void > { > var result:ArrayCollection = event.result.galleries.gallery > is ArrayCollection > ? event.result.galleries.gallery as ArrayCollection > : new > ArrayCollection(ArrayUtil.toArray(event.result.galleries.gallery)); > var temp:ArrayCollection = new ArrayCollection(); > var cursor:IViewCursor = result.createCursor(); > while (!cursor.afterLast) > { > temp.addItem(new Gallery(cursor.current)); > cursor.moveNext(); > } > galleries = temp; > } > > private function changePolicy():void { > app = new PhotoViewer(); > app.views.createComponentsFromDescriptors(); > } > } > } > > > > > --- In [email protected], "Amy" <amyblankenship@> wrote: > > > > > > > > --- In [email protected], "cjsteury2" <craigj@> wrote: > > > > > > Hey Pete, > > > > > > I see you had the same issue I am experiencing today.. and its been 1/2 a > > > day so far of pulling out hair. > > > > > > Do you remember how you solved this 3 years ago??? > > > > What you have is a race condition where the reset() function in Carousel.as > > assumes that you always have a valid Carousel, but of course the gallery > > property is beling set by a BindSetter that doesn't have anything to bind > > to until the PhotoService resultHandler has populated the photoService's > > galleries property. > > > > If you want to actually fix it, one way is to go into the PhotoService code > > and initialize the galleries variable to new ArrayCollection([new > > ArrayCollection)]); > > > > Not the cleanest solution, but that's kind of what you get when the code is > > too dependent on binding. The Carousel component unfortunately doesn't > > _know_ it's dependent on binding, so it isn't able to swallow up errors > > related to being passed in junk values via binding. > > > > If you want to just work around it, then you can just listen for > > COLLECTION_CHANGE on photoService.galleries, and switch the ViewStack pane > > once the result is received. > > > > HTH; > > > > Amy > > >

