문제

I have a component in mxml that takes a string as input and has to search for images using that string in the current folder and display the images in a HorizontalList.

Any easy way I can do this? I tried appending the strings and looking through absolute urls but its also not certain how many images there will be for a specific input.

My current code for the component looks like this:

<s:Group ..>
  <fx:Declarations>
    <fx:String id="INPUT"/>
  <fx:Declarations>

    <fx:Script>
    <![CDATA[
      import ..;

      private var arrColl:ArrayCollection;
      private var arr:Array = [ "images/" + INPUT + "a.jpg", 
                                "images/" + INPUT + "b.jpg", .. ];
      private function initHList(items:Array):void
      {
        arrColl = new ArrayCollection(items);
        myList.dataProvider = arrColl;
      }
    ]]>
    </fx:Script>

  <mx:HorizontalList id="myList" .. columnCount="2" creationComplete="initHList(arr)"/>
</s:Group>

What can I do to make the image urls more dynamic and display a variable number of images (instead of the constant 2 in the above case) in the Horizontal List?

도움이 되었습니까?

해결책

You should create a server side method that will perform the actual search, i.e. you will pass the search phrase as a parameter and as a response you will get an array of image URLs serialized as JSON, for example. Then you can parse JSON to Array and assign it as a data provider to your HorizontalList component instance. Okay, the main point here is that you cannot get the list of files on the server in Flex that is a client side application.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top