Hello - I was ust wondering how I would go about linking a button to a keyword within a .jpg file, within a folder and making that .jpg appear within a window. The word that the button will search for will not be the full name of the .jpg, it will only be part of the .jpg file name… Thanks a bunch…
Flash lacks acces to a directory tree. If you want to work with those jpegs, you need to have a list of them somewhere (i.e. XML file) and start from there. Finaly, when you have an array with filenames you can try something like this:
var filenames:Array = new Array("file1.jpg", "blueberry.jpg", "motorcycle.jpg", "strawberry.jpg");
function search(array:Array, keyword:String) {
var searchResults = new Array();
for (var i = 0; i<array.length; i++) {
if (array*.indexOf(keyword) != -1) {
searchResults.push(array*);
}
}
return searchResults;
}
function searchAndLoad(keyword:String) {
output = search(filenames, "berry");
if(output.length != 0) {
someContainerMC.loadMovie(output[0]);
} else {
trace("Sorry, no matches found for "+keyword);
}
}
someButton.onPress = function() {
searchAndLoad("berry");
};
someOtherButton.onPress = function() {
searchAndLoad("moto");
};