-
How to display multiple search results one at a time
I am trying to adapt this search code to display the results one at a time.Right now it displays all the terms it finds all at once and separated by commas. How would I adapt the code so it displays one item or term at a time.
Code:
//we count all matches
matchesArray.push(myItem01);
//length determines number of matches
var mLength:Number = matchesArray.length;
_root.textField1.text = mLength+"<FONT COLOR=\"#000000\"> matches found !</FONT>";
_root.textField2.text = "";
iDescription.push(itemDescription);
/*
var my_strtring = new String( iDescription );
var i:Number = my_str.length;
trace(my_str.slice( 1, i ));
*/
_root.mainField.text = iDescription;
}/
Any ideas would be appreciated.
-
guessing iDescription is the csv array, you could use a variable to increment by 1 and iterate through each item, as in iDescription[0] then iDescription[1] etc. until iDescription[length]
gparis
-
Thanks for the suggestion gparis. As I am almost illiterate in actionscript, I need help with coding. I tried before using something like this:
Code:
var i = mlength ;
for(var i=0;i!=mlength;i++){
_root.mainField.text = iDescription[i];
and considered adding another a textfield to announce "no more matches left!". However, that didn't work and I get "unidentified" displayed as the mainField.text. I know I must be doing something wrong but I am not good enough to discover what it is. Again any help would be appreciated.
-
no that doesn't mean anything.
What if you write that:
_root.mainField.text = iDescription[0];
instead of:
_root.mainField.text = iDescription;
Do you get the first result?
or, if you don't, try this:
_root.mainField.text = matchesArray[0];
gparis
-
Hey gparis, thank a bunch,
_root.mainField.text = iDescription[0];
did the trick and I get the trick and I get the first result!
How do I go through the rest of the resuls?
-
as i said in the first post: replace 0 by a var you increment until the end of the array by button or interval action.
gparis
-
I tried to do like this:
Code:
for (i= 0; i>wordArray.length; i++) {
_root.mainField.text = iDescription[i];
}
triggered by a button, but it didn't work. What's wrong with this?
-
Correction: that's matchesArray.length instead of wordArray.length...
Still doesn't work though.
-
no you didn't undestand. What you ask for is this:
iDescription[0];
then
iDescription[1];
then
iDescription[2];
then
iDescription[3];
etc..
How you want to call them is your choice (as i said, by button action or by interval), but using a for loop won't work if you need to display them one at a time. That is what you had before and apparently do not want anymore:
How would I adapt the code so it displays one item or term at a time
One at a time = no for loop. Read back my posts, i'm repeating myself now.
gparis
-
sorry for my ignorance in actionscript...seems like I don't know my if's from my loops!! I just want you to know that I have tried many things for the past two days with no luck. I tried code for "next" buttons like:
Code:
i == matchesArray.length-1 ? i = matchesArray.length-1 : i++;
and also if statements like:
Code:
if (i < matchesArray.length) {
i ++;
}
}else{
i = 0;
}
among many other attempts. Are these at least steps in the right direction? Would I be able to incorporate the correct code under the same "search" button that starts the function and returns the first result or do I have to insert another button (that will be the easiest route for me?
I know that it must be difficult dealing with newbies like me, but if you can find the patience to stick it out with me, it is very much appretiated. But if you cannot, I still thank you for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|