PDA

View Full Version : Search Button in Flash


Natasha
09-26-2007, 11:34 PM
Hi,

Firstly, please forgive me for my lack of knowledge but I am trying hard to learn as fast as possible!

I am working on a new webpage and purchased a template with a flash header, which has menu buttons etc. I have given myself a crash course in flash and worked out how to change the text on the buttons etc and also how to use the actionscript so that they actually work when clicked (yeah, I know, I'm so proud, but I bet you're saying "so what..that's eassssy")

Anyway, as part of the template, they provided a input text field and a search button, but there is no functionality behind it.

On my shopping cart (I'm using Romancart) they give you the code you can use for a search button which searches through the contents of the product manager (does this make sense?) and returns a page showing the results of the search - this is in the form of a list of products that can be clicked, and then codes opens the page where that product is listed.

The code I got from RomanCart is as follows:

<form action='http://www.romancart.com/search.asp' target=searchwin>
<input type=hidden value=25855 name=storeid>
<input type=text value='' name=searchterm>
<input type=submit value='Go'>
</form>

so anyway, this works fine in plain html - but how do I make the search button in my flash file do the above? Or can't I? If it's not possible to assign the above code to my flash button, then is there another way of creating a button that searches my website and returns results if the searchterm is found?

For example, at the moment there is no code behind this search field or button, but I'd like a customer to be able to type "candle" in the empty box and then press the "search" button - a page then opens with a list of all pages within my website that contains the word "candle"

I'm sorry if this post is hidiously naieve - but I am simply not aware of the correct terminology I should be using, and seeing as there's possibly only 4, perhaps 5 hairs left on my head I'm pretty desperate for some help!

Thanks

Natasha

Alexus
09-27-2007, 09:13 AM
In our menus we use Google search

m_text_clip.onRelease = function()
{

var str_url:String = "http://www.google.com/search?q=site:";
//str_url += search_site;
str_url += "&q=";
str_url += search_text;
_parent.getURL(str_url,"_blank");
}
Try to enter some word in the samples menu (http://flashmenulabs.com/examples_classic.htm) search field and press this button

Natasha
09-27-2007, 10:41 AM
Hi

That is very cool - and I did try it out, but my problem is that I want the search button to search my site only and not google.

I wanted my customers to be able to search for a particular product on MY site, whereas if they typed "candle" into a search that used google, it would go to a google page and give my customer a list of all my competitors!

yell0wdart
09-27-2007, 04:56 PM
I think his point was that you can probably edit his code and make it work, if it's just entering a search via URL. One thing you'll need to establish is, which version of ActionScript are you using. The code Alexus provided you looks like AS2.0.

I've never used RomanCart. Is it all based off server-side code that's accessing a database? If so, it sounds like you'll need to write some AS to pass the search string data into your PHP, ASP, etc, and have that server-side code issue the command to search the database, rather than AS doing the searching for you.

Natasha
09-27-2007, 05:34 PM
Yes that's right, with Romancart you input all your product into a database via their website and then just add a button to your own page which adds the product to the shopping cart - which again is displayed on my site but hosted and controlled by Romancart. The same goes for the search button - the code I pasted earlier goes and looks in the Romancart database specifically for my store and returns a page listing all the products within my store only that match the search term.

I'm using Flash CS3 Professional. With regard to all the other things you typed (php, asp etc) I don't have a clue what you're talking about. sorry

I think I'm going to have to try and find someone to do this for me and pay them. Any suggestions as to who I could use?

yell0wdart
09-27-2007, 08:37 PM
Have you thought about putting this search box anywhere on your page that's not Flash? If it saves you money, and it can go somewhere else that still fits (aesthetically) in your site, it might make more sense to do that, rather than paying somebody to do it for you.

Alexus
09-27-2007, 09:11 PM
Natasha, the code I provided work like google search definete site for some ingormation. For example, if
search_site = "www.flashmenulabs.com"
then google will search only this site for some key word.
But if you want to search your site with special Romancart engine you should try something else.
I agree with yell0wdart, it is not obligatory to use Flash to create that button, create it with technology that you know.

Natasha
09-28-2007, 06:30 PM
yes, I tried this but unfortunately the asthetics of site only really allow the search button to be placed where it is - which is in the header.

mikenaman
10-02-2007, 01:08 PM
Hi

If the html code works fine then it should be possible to translate it into a Flash function/button script.

<form action='http://www.romancart.com/search.asp' target=searchwin>
<input type=hidden value=25855 name=storeid>
<input type=text value='' name=searchterm>
<input type=submit value='Go'>
</form>

It could work like this if it is sending the data as GET


on (release)
{
getURL('http://www.romancart.com/search.asp?target=searchwin&storeid=25855&searchterm="+searchTextfeild.text,"searchwin","GET")
}

In the .fla file, add a textField and change it type from "Static" too "input". Once changed you'll be able to give it an instance name. Enter "searchTextfeild" into the <instanceName> box.

Now create a button (if you can not do this, try the help menu. Under the "All books" drop down, goto "Using Flash", goto "Using Symbols, instance etc...", goto "Working with button Symbols"). Once you've created your button add the code above to the button via the actionScript pannel (F9 key).

Let us know how you got on and if there's any tweeks need making as the code is targeting a specific html window and I don't know if it's the right one.

Thanks

Mike