View Full Version : [random image from dir]how?
scaver
09-25-2002, 03:50 PM
I want to make a intro for a flash movie.
In this intro there is a var. picture. But that picture is random from a dir..
ex.
c:\photos\album1\photo1.jpg
c:\photos\school\test.jpg
etc..
How can i make a script with this?
CyanBlue
09-25-2002, 05:51 PM
Howdy... :)
First, create an array that contains the all the names of the external files you want to load... I sugges you to move all the necessary files into one directory under the directory where your main movie file is located...
imageArray = new Array("images/photo1.jpg", "imgaes/test1.jpg", "imgaes/test2.jpg", "imgaes/test3.jpg", "imgaes/test4.jpg", "imgaes/test5.jpg");
Now, you need to get the random number between 0 to 5 since you have six elements in your array...
randNum = random(6);
Now, that randNum contains the value between 0 to 5...
Use loadMovie() function to load the appropriate pictures into the empty movieclip...
_root.imageHolder.loadMovie(imageArray[randNum]);
Get the idea??? :)
scaver
09-25-2002, 06:20 PM
Originally posted by CyanBlue
Howdy... :)
--
imageArray = new Array("images/photo1.jpg", "imgaes/test1.jpg", "imgaes/test2.jpg", "imgaes/test3.jpg", "imgaes/test4.jpg", "imgaes/test5.jpg");
---
Get the idea??? :)
I don't know the names of the images.. I even don't know the names of the sub-dirs.
Is there a function or so to get a dirlist including subdirs and put them in a file or something? Or how should I make this? It should be completely dynamic.. no static names..
CyanBlue
09-25-2002, 06:59 PM
Um... Okay... Then explain how you are going to get the name of the image file from the user...
scaver
09-25-2002, 07:21 PM
I was thinking of making a script which called every time a .exe file (written in c++) which makes a dirlisting of the dirs and subdirs which should like this:
text.txt
c:\photos\test.jpg
c:\photos\house.jpg
c:\photos\album\people.jpg
etc.
Or this done by flash?
I can read this file by flash? and put every line in a array..
something like this..
dimension = total lines in the file test.txt
dimension = text.txt
imageArray = new List (dimension.total_lines);
Array = new Filename [dimension];
for (int i =0; i < dimension; i++)
{
Array [i]= new FileName(this);
}
Something like that..Can someone help me?
CyanBlue
09-25-2002, 08:06 PM
Are you trying to create a projector or web based application???
scaver
09-25-2002, 08:21 PM
webbased...
CyanBlue
09-25-2002, 09:47 PM
Um... If that is the web based application, I don't think you can create C program that will scan the user's directory to make a list...
I think you should use JavaScript or server side script such as PHP that will create a list of user's files and then import that list into the Flash to create an array from that...
Keep it posted, brother... :)
scaver
09-25-2002, 09:53 PM
Originally posted by CyanBlue
Um... If that is the web based application, I don't think you can create C program that will scan the user's directory to make a list...
I think you should use JavaScript or server side script such as PHP that will create a list of user's files and then import that list into the Flash to create an array from that...
Keep it posted, brother... :)
I maybe can make a .exe file which runs on the server en puts output to a file. The .exe can be started by php..
or I make it in PHP.
The only problem I have in php are the sub dirs..don't know how to show them..
but i will find out.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.