1 Reply Latest reply on Jan 5, 2008 10:14 PM by VarioPegged

    don't work "creationComplete"

    gerraIrkutsk-vtxlyW
      During start of project I initialize first enter in List by selectedIndex="0" creationComplete="{liChange(event)}". It worked on a local machine and on a web server. After that I'd added ProgressBar and now it works normal only on a local machine. When I open my page on a www server then my command "creationComplete" don't activate and I see all without data from List. And only after any click on a List activate command change="{liChange(event)}" and all become good.
      If someone have a free time please look at my project. http://www.gerra.net/testirsi/IRSI_OFFERS.html There are source files too.
      Best regards, George. my project
        • 1. don't work "creationComplete"
          VarioPegged Level 2
          Seems I'm hogging the replies here! Sorry...

          On the first try I had to manually click on the list to load the first picture, so I had the same problem as you experienced. Then I cleared my cache and tried again to see if I could replicate, but it worked fine. I tried this on a different machine and had no problems whatsoever.

          From taking a quick glance at your code, it seems you have a disconnect between events. The creationComplete event on your list may be running before the dataProvider 'bookStock' is available. Then when you're setting the selectedIndex property on your dataProvider nothing happens. (BTW, I don't see why you're using curly braces in creationComplete="{liChange(event)}". Passing the event object is also redundant because you're not using it in the called function)

          How about dispatching a custom event in the main application after you've received your XML data for the picture list, then listen for that event in the compPictures component, then you can "reset" the selectedIndex for the list after you know the data is there?

          Give the HBox container for compPictures an id. Something like "picContainer". Then...
          ...
          public function onBookHandler(evt:ResultEvent):void
          {
          bookStock=evt.result.manybooks.picture;
          picContainer.dispatchEvent(new Event("dataReady"));
          //you could also have the stage dispatch the event for looser coupling
          //this.stage.dispatchEvent(new Event("dataReady"));
          }
          ...

          Then in compPictures.mxml:
          ...
          parent.addEventListener("dataReady", setListIndex);
          //or use the following if you chose the stage to dispatch the event
          //this.stage.addEventListener("dataReady", setListIndex);
          ...

          private function setListIndex(event:Event):void
          {
          liPict.selectedIndex = 0;
          }
          ...
          The following approach may be quicker to just try, although quite rigidly coupled, of course. In your main application:
          public function onBookHandler(evt:ResultEvent):void
          {
          bookStock=evt.result.manybooks.picture;
          panelPicture.liPict.selectedIndex = 0;
          }

          Also, I would then take selectedIndex="0" out of the "liPict" list control.

          TS