469,319 Members | 2,239 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

HorizontalList of images from dynamic source

Hi Everyone,

As usual, after trying what I can, I come here to ask for your help.

Once I found out that scrollToIndex was not working in Flash, but it was working within Flex, then I started to learn Flex, so I'm a newbie.

I am trying to load an xml file into flex to populate a HorizontalList of images.

I am able to populate a datagrid using the same logic with no problem, but I have yet to be able to populate the HorizontalList, and the weird thing is that, I receive no errors during compile time. When I view the app in the browser, everything looks great except within the HorizontalList, all it displays is some text "Image10" -- what???

Here's the code:
Expand|Select|Wrap|Line Numbers
  1.     <mx:XML id="tempImageXML" source="http://www.mydomain.com/image_readerH.xml" />
  2.     <mx:XMLListCollection id="cuePointImageXMLList" source="{tempImageXML.row}" /> 
  3.  
  4.  
  5.     <mx:HorizontalList width="100%" height="100">
  6.  
  7.                     <mx:Image source="@Embed('http://www.mydomain.com/images/' +String({cuePointImageXMLList}))" width="50" height="50" />
  8.  
  9.     </mx:HorizontalList>
  10.  
Thanks in advance,
Tarik (Tah-Rick)
Nov 5 '07 #1
1 5528
OK, so I've changed the flex code to load an .swf file which can load pictures, but I'm having a hard time loading pics after the initial 25 jpegs load.

Expand|Select|Wrap|Line Numbers
  1.     <mx:VBox>
  2.         <mx:SWFLoader id="Load" source="@Embed(source='readfromdir4.swf')" height="150" width="100%"/>
  3.     </mx:VBox>
  4.  
I'm trying not to load all 6,000 images into the browser's at once, so I'm trying to do it 25 at a time.

Here's how I get the first 25:

Expand|Select|Wrap|Line Numbers
  1.  
  2. var filepath:String;
  3.  
  4. if (_url.indexOf("http") != 0) filepath = "http://www.mydomain/server/";
  5. else filepath = "";
  6.  
  7. var lv:LoadVars = new LoadVars();
  8. var pics:Array = [];
  9. var mcl:MovieClipLoader;
  10. var ipic:Number;                    // index into pics, used during loading
  11.  
  12.  
  13. // function to read returned list and push items into pics array
  14. function fillPicsArray(ok) {
  15.     if (ok) {
  16.         for(i=0;i<6000;i++)
  17.         {
  18.             pics.push(this["f"+i]);
  19.         }
  20. //        trace('the directory has ' + pics.length + ' pictures');
  21.         k=0;
  22.         for(j=myPrevNumber;j<myNextNumber;j++)
  23.         {
  24.             tempPics[k] = pics[j];
  25.             k++;
  26.         }
  27.         loadPic();
  28.     } else {
  29.         trace("problem with the script");
  30.     }
  31. }
  32.  
  33. // function to execute when each picture is loaded
  34. function onLoadInit(pic:MovieClip) {
  35.     pic._width = 50;
  36.     pic._height = 50;
  37.     pic._x = 8 + 66*ipic;
  38.     pic._y = 10;
  39.     pic._alpha = 100;
  40.     pic.filters = [picShadow];
  41.     if (++ipic < tempPics.length) loadPic();
  42. }
  43.  
  44. // function that loads one pic (as pointed to in the pics array by ipic)
  45. function loadPic() {
  46.     holder.createEmptyMovieClip("p"+ipic,ipic);
  47.     holder["p"+ipic]._alpha = 0;
  48.     mcl.loadClip("http://www.mydomain.com/images/" + tempPics[ipic], holder["p"+ipic]);
  49. }
  50.  
  51.  
That's fine, but I have tried all kinds of ways to try and load the next 25 images, but to no avail.

I know the values are there and I know that it is incrementing correctly, because I am placing the values into a textarea after I've clicked on the "Next 25" button. Here's the code for the next 25.

Expand|Select|Wrap|Line Numbers
  1.  
  2. var mcl2:MovieClipLoader = new MovieClipLoader();
  3. var ml:Object = new Object();
  4. ml.onLoadInit = function(target_mc:MovieClip) 
  5. {
  6.     target_mc._width = 50;
  7.     target_mc._height = 50;
  8.     target_mc._x = 8 + 66*ipic;
  9.     target_mc._y = 10;
  10.     target_mc._alpha = 100;
  11.     target_mc.filters = [picShadow];
  12. }
  13.  
  14.  
  15.  
  16.  
  17. myNext25btn.onRelease = function()
  18. {
  19.     this.createEmptyMovieClip("holder2", 1);
  20.     myPrevNumber += 25;
  21.     myNextNumber += 25;
  22.         k=0;
  23.         for(j=myPrevNumber;j<myNextNumber;j++)
  24.         {
  25.             tempPics[k] = pics[j];
  26.             msg_ta.text += tempPics[k];
  27.             mcl.loadClip("http://www.mydomain.com/images/" + tempPics[k], ml["p"+k]);
  28.             k++;
  29.         }
  30.         msg_ta.text += myNextNumber;
  31. }
  32.  
  33. myPrev25btn.onRelease = function()
  34. {
  35.     this.createEmptyMovieClip("holder", 2);
  36.     myPrevNumber -= 25;
  37.     myNextNumber -= 25;
  38.     fillPicsArray;
  39. }
  40.  
  41. function loadPic2(k)
  42. {
  43.     holder2.createEmptyMovieClip("p"+k,k);
  44.     holder2["p"+k]._alpha = 0;
  45.     mcl.loadClip("http://www.mydomain.com/images/" + tempPics[k], holder2["p"+k]);
  46. }
  47.  
  48.  
Thanks in advance :-)
Nov 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by K | last post: by
7 posts views Thread by duncan.lovett | last post: by
8 posts views Thread by Chris Beall | last post: by
2 posts views Thread by boeledi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.