Flash Q - Load ANY .swf?
- Started
- Last post
- 12 Responses
- sisu
Hey Y'all. Is it possible to get one .swf to recognize another .swf regardless of file name (but with .swf extension)?
I'd like to be able throw two swfs in a single directory and have one swf (parent) load the other swf (child) but without knowing the childs name.
Sounds like kidnapping, I know.
- sixfngers0
you could hit a php script that returned all of the swf files in a directory. then argue against loaderInfo.url if the file name isn't the same as the swfs url then tell flash to load it.
or have php output your embed code and pass the swf to load as a flash var
- acescence0
flash security sandbox won't allow reading directories, you need something on the server to do it.
- sixfngers0
something simpler like how?
is there any other way to have flash get a list of files in a server directory other than a server script.
- kult0
The chances of a simpler solution are dependent on you elaborating how such a crazy situation could occur..
Otherwise.. PHP it is.
- acescence0
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if (substr($file, -4, 4) == ".swf") {
echo "$file\n";
}
}
closedir($handle);
}
?>
- ornj0
LOL @ kidnapping. The PHP idea is good if the issue is that you won't know the child's name ever, if it is random or something. Other wise you could pass the name at run time as a flashvar or through xml so you can easily change it as you need. One of those options is probably your best bet... you can find already written php through a google search. I was trying to post my own here but I don't have ftp access to the server hosting it.
- fugged0
if you're reading the contents of the directory, but both parent and child swfs are in there - you'll need some way of determining which is the child swf so that you don't load the parent again...
- sisu0
You guys are probably right and PHP is the solution. I appreciate your input.
I was hoping for something that didn't use php... something that that said something like 'look for any file in this directory (except self) with a swf extension and load it'.
- fugged0
why not just rename all the child swfs? batch rename that shit...
- acescence0
stage.loaderInfo.url will give you the name of the current swf within flash so you don't load that one again. you can use that php above to print all the swfs in a directory to flashvars.
- sisu0
Thank you and thank you.
- evanburke0
"something like 'look for any file in this directory (except self) with a swf extension and load it'."
That's what PHP (or any server side scripting language) is for. Not Flash.
Or do something like fugged suggested as a plan B.