1 Reply Latest reply on Mar 21, 2010 2:59 PM by jphillipcamp

    Flex 3 gallery

    IdaLinzie

      Hi, i have my xml file to get the photos into flex gallery. when i click on one of the photos they will be shown in a bigger image. what i would like to know is how i can have one of the picture in the image from the beginning? lets say it starts with pic no 1 in the image and then you can choose any picture so that image wont be blanc.

       

      My code for showing pic in canvas:

       

      <mx:Image source="{dataGrid.selectedItem.src} width="528" height="448" />

       

      thank you for help!

       

      Ida

        • 1. Re: Flex 3 gallery
          jphillipcamp

          There are multiple paths to solving this issue. 

           

          One may be to provide a creation complete event handler on the data grid to select the first item after the data grid is populated.  Then you can force the data grid to select an item and your binding should work for you.  Make sure your image source has also completed it's creation phase.  If the data grid and the image are in the same component you might consider putting the creation complete handler on the overall component.

           

          Place this in your data grid and image container (this assumes that the data has been already assigned to the data grid at creation complete):

           

          creationComplete="setFirstImage()"

           

          And this in a script block or your code behind as:

           

          <mx:Script>

          <![CDATA[

          private function setFirstImage():void

          {

          dataGrid.selectedIndex = 0;

          }

          ]]>

          </mx:Script>

           

          If the data is asynchronous just make sure to set the selected index after the data is assigned to the data grid's data provider.

           

          Did I understand the question? Does this help?

           

          Best,

           

          J. Phillip Camp

          1 person found this helpful