?
Solved

Giving Search for a flash file

Posted on 2003-03-05
16
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +1
16 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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