A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Dynamic Image Holders

  1. #1
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    You know how there are basic HTML pages that contain thumbnails of images? Well, I would like to do one in Flash. Say I have a Flash page with multiple "boxes" named occordinally box"1-18". Basically, I just want to be able to drop images into my images folder, and Flash will automatically detect them and add them into the slots. If there are no images, it will remain blank. Anyone have a good start on this?

  2. #2
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Okay, here is some code i've been expirementing with...

    On my screen, I have 24 boxes with instance names box1, box2, etc...

    Code:
    i = 1;
    for (i; i<25; i++) {
    	loadMovieNum("\"i\"+.jpg", "box+\"i\"");
    	trace(i);
    }
    It doesnt load any .jpgs

    Hope that helps!
    [Edited by wiReZ on 07-29-2002 at 06:13 PM]

  3. #3
    Code:
    directory = "photos/";
    loadMovie(directory add MATH add ".jpg");
    stop();
    I think you need a directory set to load pictures from, and make sure they are numbers 1.jpg, 2.jpg, etc...give it a try, I'm not entirely sure (new to AS).

    what version are you using? F5 can't load jpgs...you'd have to use a individual swf for each of them...mx can, hope you've got mx...

    [edit]wait...this is the MX section...*slaps self*[/edit]

  4. #4
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    That's not the problem, thanks for trying though.

  5. #5
    well, if you want a random image loader:
    Code:
    images = 25;
    directory = "randimg/";
    randomswf.loadMovie(directory add Math.ceil(Math.random()*images) add ".jpg");
    stop();
    that works. although its not really what your after...that's my first foray into AS. But, hey, maybe it'll give you an idea.

  6. #6
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Hehe, not to sound rude or anything but I know what I want, I understand what your putting, but it does not help contribute toward anything I am doing. Sorry, thanks anyway though.

  7. #7
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    bump...

  8. #8
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    maybe?
    Code:
    image = "" + i + ".jpg"
    target = "box" + i
    target.loadMovie(image);

  9. #9
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Where would I put that?

  10. #10
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    again, i'm not sure but...

    inside the for loop...

    Code:
    number_of_images = 25
    for (var i = 1; i < number_of_images; i++) {
         image = "" + i + ".jpg"
         target = "box" + i
         target.loadMovie(image);
    }

  11. #11
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    your images are named 1.jpg, 2.jpg, etc... right? boxes are box1, box2, etc... ?

  12. #12
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Correct.

  13. #13
    Poof! Whaddya need? I'mFine's Avatar
    Join Date
    May 2001
    Posts
    345

    You're so close!

    I think it's just a minor syntax problem, really. You've done most of the work.

    Your code is:
    Code:
    i = 1;
    for (i; i<25; i++) {
    	loadMovieNum("\"i\"+.jpg", "box+\"i\"");
    	trace(i);
    }

    Try;
    Code:
    for (i=1; i<=25; ++i) {
         loadMovie (i+".jpg", "box"+i);
    }
    -------------------------------------
    Explanation: LoadMovieNum will try to load your JPEG to a level. You want to load to a target, so you just need loadMovie.

    Your method of setting the counter i was a little off. Set its initial value in the "for" statement. And since you have 25 images, you don't want to stop at 24. The <= will make sure you catch the 25th one. Finally, I like to increment i before running the rest of the command. Would probably work either way, since I'm letting it continue when i reaches 25.
    --------------------------------------

    works fine for me.... let me know.

  14. #14
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Ah it works! Thanks man! I noticed the LoadMovieNum problem a few minutes ago. And actually, it only goes to 24 images. Works like a charm otherwise. Now the next step. I want the image to load only in the area given by the MC. So, I dont want it to overlap. Is that somewhat possible?

  15. #15
    Poof! Whaddya need? I'mFine's Avatar
    Join Date
    May 2001
    Posts
    345

    scale before or after

    The easiest thing to do, of course, is to make your jpeg the right size to begin with.

    But of course, there's a hard way too!

    Do this:
    Code:
    box1._x=200;
    box1._y=200;
    or
    Code:
    box1._xscale=50;
    box1._yscale=50;
    The first is used to set an absolute size in pixels, the second allows you to scale by percent. You'd put either one of these methods after the AS that imports the images.

    Cool?

    --Rissa

  16. #16
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Okay, sounds great, now another "dilemma". Is there a way to detect if the image is not loaded, then spit out an MC saying "Movie Not Loaded"? Just a thought...

  17. #17
    Poof! Whaddya need? I'mFine's Avatar
    Join Date
    May 2001
    Posts
    345

    love a challenge

    oooooh I just love a challenge...

    Here ya go! So there!

    Code:
    for (i=1; i<=24; ++i) {
         loadMovie (i+".jpg", "box"+i);
    	 if (this[i+".jpg"].onLoad(true)) {
    		trace ("loaded"); // my test: put whatever
    	 } else {
    		 trace (i+"failed"); // ditto
    	};
    }
    --Rissa

  18. #18
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    Unfortunatly, that code does not work. It always outputs the images as if they failed, even though they are loaded. But it's no biggie, It wasn't necessary, thanks for all your help though, greatly appreciated.

  19. #19
    Poof! Whaddya need? I'mFine's Avatar
    Join Date
    May 2001
    Posts
    345

    sorry, my bad

    Hey wiReZ

    That's what I get for trying to do something at quitting time on the day before a day off!

    I must've had the output window too small -- as soon as I saw that the last image had failed to load, I thought I'd solved it.

    I've tried a few more ideas, but haven't gotten there so far. It's a good idea, though, so I may try again a little later. If I come up with something, I'll let you know.

    --Rissa

  20. #20
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Have you checked the tutorial the ultimate slideshow MX under dynamic content on the flashkit site?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center