ciju
asked on
Giving Search for a flash file
Hi
I have a flash file which has a text tool(just one text tool) lengthy enough to put all Branch Address.
I want to give a text box(text tool) on top of the file and a search button, so that typing a word which will be present in the text field below should point to that word in this text tool below.
is it possible.
Any help would be appriciated.
I have a flash file which has a text tool(just one text tool) lengthy enough to put all Branch Address.
I want to give a text box(text tool) on top of the file and a search button, so that typing a word which will be present in the text field below should point to that word in this text tool below.
is it possible.
Any help would be appriciated.
ASKER
Thats right...
I have 2 text boxes :
1. tbox1 : where i type a word to be searched
2. tbox2 : here in this i have all the address of branches
when i enter a word in tbox1 and click on search button if a match is found then that word has to be highlighted in tbox2.
How is it possible can u give me the steps to do this and any sample script.
I am using Macromedia Flash MX Ver 6.0
I have 2 text boxes :
1. tbox1 : where i type a word to be searched
2. tbox2 : here in this i have all the address of branches
when i enter a word in tbox1 and click on search button if a match is found then that word has to be highlighted in tbox2.
How is it possible can u give me the steps to do this and any sample script.
I am using Macromedia Flash MX Ver 6.0
hehe...I'm confused too..
is it two text box? or 1 text box and 1 combo box?
is it two text box? or 1 text box and 1 combo box?
ASKER
Its text box which is created using the 'Text Tool' in flash.
Just 2 text boxes created using the 'Text Tool'
Just 2 text boxes created using the 'Text Tool'
that's what u do, us the selection object to hightlight the text and index of to search for an exact match keywords
have 2 boxes, one call tbox1 and the other tbox2
tbox1 -> variable = txt
tbox2 -> variable = keyword
have a button and run the function search
on(release) {
search()
}
var txt = "here u have to put in all the text u want" + newline + "if different records are separated by newline";
function search(){
if (midx!=-1)
{ sidx=midx+1;}
else { sidx = 0;}
midx = txt.indexOf(keyword, sidx);
hi = new selection();
Selection.setFocus("tbox1" )
si = midx
ei = midx+ String(keyword).length
Selection.setSelection(si, ei);
}
stop();
... etc .. etc
cheers
have 2 boxes, one call tbox1 and the other tbox2
tbox1 -> variable = txt
tbox2 -> variable = keyword
have a button and run the function search
on(release) {
search()
}
var txt = "here u have to put in all the text u want" + newline + "if different records are separated by newline";
function search(){
if (midx!=-1)
{ sidx=midx+1;}
else { sidx = 0;}
midx = txt.indexOf(keyword, sidx);
hi = new selection();
Selection.setFocus("tbox1"
si = midx
ei = midx+ String(keyword).length
Selection.setSelection(si,
}
stop();
... etc .. etc
cheers
ASKER
I am new to Flash & Flash Scripting, could you pls tell me the follwoing :
I have created 2 text boxes using the Text tool as u said.
Also gave the variable name as u mentioned.
My doubt is:
Should the text Type be : Input Text, Static Text or Dynamic text, in both the cases. And the instance name?
Should i have to paste the above complet code in the onRelease() event of the button?
My variable text is a big static text ranging 3 pages(approx), then assing such a big text to a variable?
I have created 2 text boxes using the Text tool as u said.
Also gave the variable name as u mentioned.
My doubt is:
Should the text Type be : Input Text, Static Text or Dynamic text, in both the cases. And the instance name?
Should i have to paste the above complet code in the onRelease() event of the button?
My variable text is a big static text ranging 3 pages(approx), then assing such a big text to a variable?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i am also new to flash and scripting and sorry if im such a pain in the neck, but i want to understand the code u wrote Henry..can u plz explain it..i mean just comment ur code like what do u mean by " if (midx!=-1) " and what is midx anyway!?!?!
Samah.
Samah.
ok ... this search function actually looks for more than 1 occurence of the keyword u are searching ...
function search(){
if (midx!=-1)
{ sidx=midx+1;}
else { sidx = 0;}
midx = txt.indexOf(keyword, sidx);
hi = new selection();
Selection.setFocus("tbox1" )
si = midx
ei = midx+ String(keyword).length
Selection.setSelection(si, ei);
}
initially
midx = null
sidx = null
when search starts - result not found
midx = -1 ...
if
var txt = "here u have to put in all the text u want" + newline + "if different records are separated by newline";
keyword look for is = "a"
search function 1st press
sidx = 0 <- start search from postion 0
midx = txt.indexOf(keyword, sidx);
then
midx = 8
search function 2nd time
sidx = 8; // = midx; start search from position 8
midx = txt.indexOf(keyword, sidx);
midx = 20;
... etc
so if u don't change the keyword and hit the search button again, it will look for the next occurence of the keyword instead of stopping at the 1st one all the time.
cheers
function search(){
if (midx!=-1)
{ sidx=midx+1;}
else { sidx = 0;}
midx = txt.indexOf(keyword, sidx);
hi = new selection();
Selection.setFocus("tbox1"
si = midx
ei = midx+ String(keyword).length
Selection.setSelection(si,
}
initially
midx = null
sidx = null
when search starts - result not found
midx = -1 ...
if
var txt = "here u have to put in all the text u want" + newline + "if different records are separated by newline";
keyword look for is = "a"
search function 1st press
sidx = 0 <- start search from postion 0
midx = txt.indexOf(keyword, sidx);
then
midx = 8
search function 2nd time
sidx = 8; // = midx; start search from position 8
midx = txt.indexOf(keyword, sidx);
midx = 20;
... etc
so if u don't change the keyword and hit the search button again, it will look for the next occurence of the keyword instead of stopping at the 1st one all the time.
cheers
ASKER
I am using Macromedia Flash MX Ver 6.0
Any way to add it in flash as u have said (depends on version of flash u have, there are many ways to load txt into flash.)like using an XML? Or other way
Any way to add it in flash as u have said (depends on version of flash u have, there are many ways to load txt into flash.)like using an XML? Or other way
yes ... if u don't want to change the text file or if the text file is being update all the time by different end users ... just use it "as is" then use an XML object and load it...
eg
//frame 1
myText = new XML();
myText.load("http://yourdomain/full.txt");
myText.onLoad = function (){
_root.txt = myText.toString();
delete myText;
}
// now u have the full.txt into the variable call txt in root, that just carry on with the rest.
eg
//frame 1
myText = new XML();
myText.load("http://yourdomain/full.txt");
myText.onLoad = function (){
_root.txt = myText.toString();
delete myText;
}
// now u have the full.txt into the variable call txt in root, that just carry on with the rest.
a big THANX to u Henry, i got it :)
well ... it sounded like u had asked this question Samah.
but that's cool :)
cheers
but that's cool :)
cheers
:D
u mean u have a textbox filled with text (tbox1) ... and another box (tbox2) to type in the keyword and click a button to searh. if a match is found then u want that highlighted in the (tbox1) ??
and the question is "is it possible."
yes ... it can be done. easily in flash MX
cheers :)