Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Giving Search for a flash file

Posted on 2003-03-05
16
Medium Priority
?
186 Views
Last Modified: 2010-04-03
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.
0
Comment
Question by:ciju
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8078096
can u explain that again ...
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 :)
0
 

Author Comment

by:ciju
ID: 8078240
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
0
 
LVL 5

Expert Comment

by:elhy
ID: 8078245
hehe...I'm confused too..

is it two text box? or 1 text box and 1 combo box?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ciju
ID: 8078277
Its text box which is created using the 'Text Tool' in flash.

Just 2 text boxes created using the 'Text Tool'
0
 
LVL 6

Expert Comment

by:henryww
ID: 8081646
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
0
 

Author Comment

by:ciju
ID: 8093245
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?

0
 
LVL 6

Accepted Solution

by:
henryww earned 120 total points
ID: 8093386
for the keyword, u should set it as input and the one contains all the data is a dynamic text box

u put all the code in frame 1 if u like and have the button to call the search funtion

so ... for the button

on (release) {
 search();
}

// is the so call big text ...
var txt = "here u have to put in all the text u want" + newline + "if different records are separated by newline";

now if u have 3 pages and u don't really want to type it in again right .. depends on version of flash u have, there are many ways to load txt into flash.

u can do with xml object or change the txt format a bit like

txt= .... all+ur+text+here ... escaped ... etc ...

0
 

Expert Comment

by:Samah
ID: 8093457
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.
0
 
LVL 6

Expert Comment

by:henryww
ID: 8094549
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

0
 

Author Comment

by:ciju
ID: 8097057
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
0
 
LVL 6

Expert Comment

by:henryww
ID: 8097122
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.
0
 

Expert Comment

by:Samah
ID: 8098686
a big THANX to u Henry, i got it :)
0
 
LVL 6

Expert Comment

by:henryww
ID: 8098790
well ... it sounded like u had asked this question Samah.
but that's cool :)

cheers
0
 

Expert Comment

by:Samah
ID: 8098944
:D
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question