-
Display Random Images
Is there an easier way to display random images, for example I want it to display an image or two and then three or four second’s later change to another.
I have over 100 images to display and don’t really want create each frame and place a new image on every 5 or so frame.
There must be somewhere out there some action script that can do this, can anyone help I would very much appreciate it, and thanks in advances for your help.
0rlando
-
Lifesaver
Are you loading these images from an external JPG file or do you plan to embed them into your Flash movie?
If you're using external JPGs (say in a folder called "images",) try this:
code:
myImageArray = ["image01.jpg", "image02.jpg", "image03.jpg", "image04.jpg"];
_global.changeImage = function() {
myImage = myImageArray[random(myImageArray.length)];
someMovieClip.loadMovie("images/" + myImage);
clearInterval(_root.changeImageIval);
_root.changeImageIval = setInterval(changeImage, ((random(10)+1) * 1000) );
}
_root.changeImageIval = setInterval(changeImage, ((random(10)+1) * 1000) );
//executes changeImage function after random milliseconds
You would need a movie clip called "someMovieClip" to load the images into. In this case, the images need to be located in a folder in your app dir called "images".
This should just about do it...I didn't test the code, but I'm pretty sure it works.
Hope this helps!
-
i am looking to do the same thing and i was wondering where you put that actionscript. do put it on the someMovieClip file, or do you go into the movie clip and put it in a frame? Thx.
-
Lifesaver
You should be able to copy this AS and paste it into any frame of your Flash movie. You would be REQUIRED to have a Movie Clip with an instance name of "someMovieClip" located in the same level as the code. According to this code, you would also need to put your images in a folder called "images" within your Flash Movie's working folder.
Hope this helps!
-
The code provided by Lightwave indeed works great in flash moviclip .
THe images changes their order randomly well without any error .
Want a help regarding this code :
Is there any way to fade out the images .i.e one image fades out and other fades in ??
I presume this can be achieved by alpha values , but dont know how .
There is only single frame in my flash movie which plays this action . If I add more frames for a motion tween , the whole movie ( other layers as well ) gets affected and destroys the functioning .
Can anyone help please ? Wud be highly appreciated .
Regards ,
Dr.Jatin Talwar
M.S (Orthopaedics)
-
Help needed
Hi,
I'm trying to implement your code and i'm not having any success. I've created an empty movie called 'someMovieClip' and placed it on the stage. There is an empty key frame with your code (copied exactly from this message board). I also have a folder place inside the directory called 'images'. I exported the movie in the directory root but nothing happens when i open it?
Any ideas what i'm doing wrong? many thanks in advance,
Richard
Originally Posted by Lightwave Network
Are you loading these images from an external JPG file or do you plan to embed them into your Flash movie?
If you're using external JPGs (say in a folder called "images",) try this:
code:
myImageArray = ["image01.jpg", "image02.jpg", "image03.jpg", "image04.jpg"];
_global.changeImage = function() {
myImage = myImageArray[random(myImageArray.length)];
someMovieClip.loadMovie("images/" + myImage);
clearInterval(_root.changeImageIval);
_root.changeImageIval = setInterval(changeImage, ((random(10)+1) * 1000) );
}
_root.changeImageIval = setInterval(changeImage, ((random(10)+1) * 1000) );
//executes changeImage function after random milliseconds
You would need a movie clip called "someMovieClip" to load the images into. In this case, the images need to be located in a folder in your app dir called "images".
This should just about do it...I didn't test the code, but I'm pretty sure it works.
Hope this helps!
-
.
hi,
That code above works as I tested it, it can take up to 10 seconds for the first event to happen, then it continues with gaps of between 1 - 10 seconds for the next image to occur, it could however pick the same number numerous times on the trot and seem like nothing is changing.
-
This may be an issue of Actionscript version.
The above code is originally from 2004 and is AS2. Make sure your publish settings are AS2. If you are using Flash CC you will not be able to use this code without converting it to AS3.
Originally Posted by thomorw
Hi,
I'm trying to implement your code and i'm not having any success. I've created an empty movie called 'someMovieClip' and placed it on the stage. There is an empty key frame with your code (copied exactly from this message board). I also have a folder place inside the directory called 'images'. I exported the movie in the directory root but nothing happens when i open it?
Any ideas what i'm doing wrong? many thanks in advance,
Richard
-
You guys are really nice and nice post, shared with all. I really appreciate it and would like to say thanks to you that you share this post here with us.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|