PDA

View Full Version : Search Function for Flash Content



e_owen
February 17th, 2009, 04:49 PM
Alright everyone?
I want to build search functionality into my AS3 app, whereby I would give some MovieClips their own relevant 'tags' and check whether any of the tags match the search items the user has put in - the objects would then be sorted depending on how much they match the search. I am thinking to put the tags for each object in an array and then go through them and look for matches, it is possible there would be multiple matches for each search request and I will need to split the search string on each 'space' (spacebar) to allow for multiple search terms. Also, I want to run the search every half second or so and so the search term could match the first few letters of a tag and this should return a positive match. Am I thinking along the right lines?

Any advice or guidance would be very appreciated.

Thanks.

.ral:cr
February 18th, 2009, 01:17 AM
what are you trying to search?

e_owen
February 18th, 2009, 06:20 AM
what are you trying to search?

I am trying to search an array of tags / keywords that I will define for each object.

The best example I can give of what I am trying to create is the 'Search' in iTunes or 'Spotlight' in OSX where your search in constantly refined as you type.

pixelsguy
February 18th, 2009, 06:24 PM
so you would want to run the search every time the input text field is changed. This is going to be more efficient than running it on a recurring timer. What you may really want to do is have a timer to delay the start of the search. this timer would be reset and started every time the user changes the textfield. this would prevent you from searching based on text that is actively being typed. You could still have it be a short delay timer, say, half a second, but it would def. be better than having it fire off a new search event every time something is typed.

that being said, i would perhaps place your "tags" on a single string associated with each of your potential result objects. running a match or a lastIndexOf or a search method on a single string is bound to be faster than running it on each string in an array of strings, and it is bound to give you more partial results, faster.

maybe you could separate your strings with an underscore or something just to make it more readable.

hope this helps.