# Dynamic jpeg loader

**URL:** <https://forum.kirupa.com/t/dynamic-jpeg-loader/300>\
**Category:** Uncategorized\
**Created:** [July 12, 2002, 7:25pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300 "2002-07-12T19:25:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashghost](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@flashghost](https://forum.kirupa.com/u/flashghost)\
**Post date:** [July 12, 2002, 7:25pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/1 "2002-07-12T19:25:32Z")

</div>

How do edit the code in the photo gallery so that I can search for next jpg 1.jpg, 2.jpg etc and then when it hits the last one it will start to the first one

I have it set to  
pic = “1”  
pic + “.jpg”

this way I can change the number of pics in the folder without changing the code?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2002, 4:23pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/2 "2002-07-13T16:23:27Z")

</div>

It’s done already. With this _very nice_ line in the prototype changePhoto :

```auto
this.pIndex = (this.pIndex+d)%this.pArray.length;

```

Until the last picture, the right part will return pIndex, and just for the last picture, it will return 0, so you’ll be at the beginning again.

% is a little bit strange : it’s the rest of the division.

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2002, 7:27pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/3 "2002-07-13T19:27:29Z")

</div>

So one minute I can have 10 jpegs and the next day 20 and it will work the same without editing the file?

I understand the array, I do not want one! that way it can be truely dynamic and not a static array!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2002, 4:43pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/4 "2002-07-14T16:43:24Z")

</div>

It means that if you want to change something, all you have to do is change the array and upload the corresponding pictures. How more dynamic can it get ?

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2002, 1:41pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/5 "2002-07-15T13:41:34Z")

</div>

What I am trying to figure out is to enter code that will automatically keep adding 1 to .jpg until there is no file and then it will start over. That way I can change the folder contents WITHOUT CHANGING THE CODE every single day.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2002, 1:56pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/6 "2002-07-15T13:56:05Z")

</div>

You can’t do it with Flash only. You’ll have to use backend. PHP for instance. Not too hard, but you must have a server that supports PHP (or ASP).

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2002, 2:46pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/7 "2002-07-15T14:46:05Z")

</div>

Is there something in actionscript that is like 'error handleing" that way is can say along the linds…if attempt to retrieve image failes then start over with pic = 1?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2002, 4:11pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/8 "2002-07-15T16:11:38Z")

</div>

Nope. You have to use PHP, man. Sorry:\*(

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 16, 2002, 2:57pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/9 "2002-07-16T14:57:11Z")

</div>

Thanks!

I guess I will have to stick to a static amount of pics and then just change them instead…

Thanks again…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 16, 2002, 3:18pm UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/10 "2002-07-16T15:18:05Z")

</div>

hmm… PHP is a good answer, and probably the one that will offer the most flexibility.

You could load array from variables in a text file, that way, the array is dynamic, so you can leave your swf alone. When you add pics to the folder, add some values to the txt file and have flash build the array from the items in the text file. Otherwise, if you want to be totally dynamic, build your MySQL database where you will put your pics, insert new pictures with php/html front end, this will automatically assign the new pic a new name in sequence (lastnameused+1). Then, have php build the array for you and feed it to flash.

That is about as dynamic as you can get…

you may still have to take the pictures yourself! ahahahahahaah

just kidding, dude.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 17, 2002, 12:05am UTC](https://forum.kirupa.com/t/dynamic-jpeg-loader/300/11 "2002-08-17T00:05:17Z")

</div>

Iammontoya how are you formatting the text file to have flash read the array properly?
