Skip to main content
Known Participant
January 14, 2007
Question

Randomly loaded .jpg's

  • January 14, 2007
  • 5 replies
  • 520 views
Hello everybody.. I know this isn't a terribly difficult thing to execute, at least conceptually, but for me with ActionScript the devil is in the details.. so anyways...

I want to have some movie clips that will randomly load images from a specified image folder, every time the is brought to this specific frame, they would encounter a new series of images. I'm familiar with using a move clip loader, and I know there are ways to make things random within Flash.

What I'm not sure about, however, is how to integrate the two, where if perhaps I had a folder of image001.jpg, image002.jpg, etc. that I could use something which would select these images randomly - this is still in it's conceptual stages at the moment, but any input would be appreciated greatly. Much thanks.
This topic has been closed for replies.

5 replies

Participant
January 26, 2007
hello there, I have a better version fot you...

you make a mc named "hold_mc"
make a folder named "img" where you have your images(*.jpg)
use this script on your first frame:


for(i=0;i<=5;i++){
j = random(i);
_root["hold_mc"].loadMovie ("img/" + j + ".jpg");
}

for more info: wizard5pccom@yahoo.com
January 23, 2007
Change your goToAndPlay to gotoAndPlay - Lower case T in goto.

Then it works fine.

Osh...
Participant
January 23, 2007
Thanks.

The curse of TTF (Typing Too Fast).

Also - another reason to hate case-sensitivity.
Participant
January 23, 2007
I've posted an example movie to show the problem here:
http://www.21ca.com/flash/randombug.zip (about 5k)

Somebody please help save what little shred of sanity I have left.

Many thanks.
Participant
January 18, 2007
Ok, I'm trying to simplify this and it's just making me nuts.

Here's a scenario that (I think) ought to work, but doesn't:

1) make a movie clip with three named layers ("pic", "actions", "labels")
2) on the labels layer, make six named frames, five or ten frames apart ("a1", "a2", "a3... thru "a6")
3) in each named frame, on the actions layer, put a stop(); action
4) in each named frame, on the pic layer, put a different bitmap so you can see something different when you arrive at that frame.
5) return to the root level time line, make three layers ("pic", "button", "actions"). Put a stop(); action in the actions layer
6) put the completed movie clip of pictures on first frame of the root timeline, in the pic layer. Give it the instance name "pix"
7) make a generic button on first frame of the root timeline, in the button layer.
8) add this script to the button:

on (release) {
var myPick;
y = random(6);
if (y == 0) { myPick = "a1"; };
if (y == 1) { myPick = "a2"; };
if (y == 2) {myPick = "a3"; };
if (y == 3) { myPick = "a4"; };
if (y == 4) { myPick = "a5"; };
if (y == 5) { myPick = "a6"; };
_root.pix.goToAndPlay (myPick);
}

Test the movie. Click the button. Nothing happens.

If you trace (myPick) you can see it's operating correctly.

If you comment out the random script and just make the button do _root.pix.gotoAndPlay("a6");, that works... Arrgh.

What am I missing?


Inspiring
January 14, 2007
here's the basic drill:
Known Participant
January 15, 2007
Much thanks for the help!

Is it considered spam here to reply to an answer with a thank you? Not 100% sure what the community guidelines are here..


but thanks again!