Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-27-2006, 05:55 PM   #1
siphon
arroz
 
siphon's Avatar
 
Join Date: Dec 2004
Posts: 82
Question loading random .swf from separate folders

I've reviewed this thread and found it very helpful.

I was wondering what the AS would look like if i had the .swf files in separate folders... For instance, I have 6 folders with 12 images in each and I want it to randomly pick one picture and load it out of one of those 4 folders.

So how would the action script look like for something like this?

Thank you
siphon is offline   Reply With Quote
Old 02-27-2006, 11:07 PM   #2
goliatone
...
 
goliatone's Avatar
 
Join Date: May 2003
Location: barcelona
Posts: 1,118
Default

ActionScript Code:
var folder=random(6);//made it to six folders, just make it 12 var file=random(6); folder_array=new Array("f0","f1","f2","f3","f4","f5");//put real folders' name file_array=new Array("file0.swf","file1.swf","file2.swf","file3.swf","file4.swf","file5.swf");//put real files' name var url=folder_array[folder]+"/"+file_array[file]; mc.loadMovie(url);
that would make the trick...
goliatone is offline   Reply With Quote
Old 02-28-2006, 01:14 AM   #3
glantucan
newbe forever!
 
glantucan's Avatar
 
Join Date: Oct 2004
Location: Madrid, Spain
Posts: 88
Default

Interesting
Is there any way to do it if you don't know th file names? and/or the number of them?

Always wanted to know this

Glantucan
glantucan is offline   Reply With Quote
Old 02-28-2006, 01:19 AM   #4
goliatone
...
 
goliatone's Avatar
 
Join Date: May 2003
Location: barcelona
Posts: 1,118
Default

uh, i guess that if the only weapon you have is flahs, you cant...you need to use a server side script to read a directory and pass it the info to flash. You could do something like that with php.

Basically, you would need to sendAndLoad a php script that reads a directory and generates an xml output or something.
goliatone is offline   Reply With Quote
Old 02-28-2006, 01:22 AM   #5
goliatone
...
 
goliatone's Avatar
 
Join Date: May 2003
Location: barcelona
Posts: 1,118
Default

no me habia dado cuenta de que eras de madrid!! me han dixo que el F.Perez se retira! jejejeje. Vivo en Bcn. Nos vemos por aqui.
goliatone is offline   Reply With Quote
Old 02-28-2006, 04:37 AM   #6
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Default

Quote:
Originally Posted by siphon
I've reviewed this thread and found it very helpful.

I was wondering what the AS would look like if i had the .swf files in separate folders... For instance, I have 6 folders with 12 images in each and I want it to randomly pick one picture and load it out of one of those 4 folders.

So how would the action script look like for something like this?

Thank you
If you use standard prefix for the naming convention for your folders and images and fixed their numbers, then you don't have to store all of them in an array. You just use the numbering range to perform random pick. Say for example, 6 folders respectively named as "folder0","folder1","folder2","folder3","folder4", "folder5" and in each of the folder, the 12 images are named as "image0","image1"...."image2" respectively.

So all you have to do is to use Math.random() to pick a folder (0 to 5) first, then followed by the image (0 to 11). From this, you form the path to the jpg image.
fugitive123 is offline   Reply With Quote
Old 02-28-2006, 08:33 AM   #7
glantucan
newbe forever!
 
glantucan's Avatar
 
Join Date: Oct 2004
Location: Madrid, Spain
Posts: 88
Wink

Quote:
Originally Posted by goliatone
no me habia dado cuenta de que eras de madrid!! me han dixo que el F.Perez se retira! jejejeje. Vivo en Bcn. Nos vemos por aqui.
Jejeje, vaya sorpresa, ... Pues sí que nos veremos por aquí, porque vivo en Barcelona desde hace un año
Y del F.Perez, no sé nada porque el futbol no se cuenta entre mis pasiones. De hecho (que no se enteren mis amigos de madrid) me alegro bastante de que al Madrid le vaya mal. Acabe harto de que okuparan la Cibeles un montón de rapaos cada vez que ganaban
glantucan is offline   Reply With Quote
Old 02-28-2006, 03:47 PM   #8
siphon
arroz
 
siphon's Avatar
 
Join Date: Dec 2004
Posts: 82
Default gracias

gracias estoy feliz con todo, esta trabajando perfecto

Thnx this has really helped out
siphon is offline   Reply With Quote
Old 02-28-2006, 03:59 PM   #9
siphon
arroz
 
siphon's Avatar
 
Join Date: Dec 2004
Posts: 82
Default

Quote:
Originally Posted by fugitive123
If you use standard prefix for the naming convention for your folders and images and fixed their numbers, then you don't have to store all of them in an array. You just use the numbering range to perform random pick. Say for example, 6 folders respectively named as "folder0","folder1","folder2","folder3","folder4", "folder5" and in each of the folder, the 12 images are named as "image0","image1"...."image2" respectively.

So all you have to do is to use Math.random() to pick a folder (0 to 5) first, then followed by the image (0 to 11). From this, you form the path to the jpg image.
using the Math.random() if i have 4 folders and each have a diffrent ammount of images in them would the code have to say something like.. "if folder01 is picked then only select 0-12RN, if folder02 picked only select 0-22RN, etc.." if so .. how complicated would the code be ?

for right now i have it set up to select 1 of 4 random .swf files (each containing one of the 4 folders) which in turn will then generat another Math.random() for the coresponding number of images with in the folder... it just seems sloppy to me i would like it all in one code just one .swf file

Last edited by siphon; 02-28-2006 at 04:05 PM.
siphon is offline   Reply With Quote
Old 02-28-2006, 04:32 PM   #10
goliatone
...
 
goliatone's Avatar
 
Join Date: May 2003
Location: barcelona
Posts: 1,118
Default

Quote:
Originally Posted by siphon
gracias estoy feliz con todo, esta trabajando perfecto

Thnx this has really helped out
...good
goliatone is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading random dynamic text without php bucklips ActionScript 2.0 7 11-06-2005 01:18 AM
Drag and Drop: Loading individual .swf files ruban ActionScript 2.0 1 11-26-2004 05:35 AM
Loading a random image from an external array jiggystar Simple Stuff (Newbies) 2 11-17-2004 02:59 PM


All times are GMT. The time now is 03:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.