# .jpg search button

**URL:** <https://forum.kirupa.com/t/jpg-search-button/185647>\
**Category:** Uncategorized\
**Created:** [April 14, 2006, 10:49pm UTC](https://forum.kirupa.com/t/jpg-search-button/185647 "2006-04-14T22:49:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![malikah](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@malikah](https://forum.kirupa.com/u/malikah)\
**Post date:** [April 14, 2006, 10:49pm UTC](https://forum.kirupa.com/t/jpg-search-button/185647/1 "2006-04-14T22:49:12Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 14, 2006, 11:33pm UTC](https://forum.kirupa.com/t/jpg-search-button/185647/2 "2006-04-14T23:33:56Z")

</div>

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:

```auto
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");
};

```
