Skip to main content
October 10, 2006
Answered

How to find out if list contains text?

  • October 10, 2006
  • 2 replies
  • 329 views
I am using the following code with a list component in Flash 8:


my_list.change = function(evt:Object) {
getURL(evt.target.selectedItem.data);
};
my_list.addEventListener("change", my_list);


I would like to define 2 behaviors - one geturl in blank window and one geturl in self - depending on whether the list data for the particular entry contains "pdf". Is it somehow possible to do this?

Many thanks in advance
This topic has been closed for replies.
Correct answer foozebox
Sure, try the indexOf() method of a string:

var url:String = evt.target.selectedItem.data;

if(url.indexOf('.pdf') != -1) { // check for existence of .pdf in the url string
//do pdf behavior
}else{
//do other behavior
}

2 replies

October 10, 2006
Thank you very much! I actually thought I'd never figure this one out. It works.
foozeboxCorrect answer
Participating Frequently
October 10, 2006
Sure, try the indexOf() method of a string:

var url:String = evt.target.selectedItem.data;

if(url.indexOf('.pdf') != -1) { // check for existence of .pdf in the url string
//do pdf behavior
}else{
//do other behavior
}