Alan Edwardes

Google Search Form In Flash

My supery-dupery new design for Alan Unleashed games was getting a bit boring, so I decided to add a search box. Just a plain old search box, pointing to Google's sitesearch. Simple to do? No.

I spent about 3 hours looking on discussion forums and tutorials for ways to convert html to flash - but no-one had made a useful one hitting the nail on the head for a Google search, so here is what I am going to do.

Preparation

Open up Macromedia Flash (in this case version 8.) and hit Create New -> Flash Document on the welcome screen. Make sure your site is indexed by Google, ie. So if you visited a link like this, it would be full of entries for your website.

Creating The Button and Editable Text Area

Even though Macromedia Flash 8 comes with built in form components (accessible via Window > Components), I found that you had to create your own, because you cannot set a variable for the text input area which is required for the search.

To create a button, just create a normal box or circle, and perhaps you could put the word "Search" over it, then convert it to a button.

search.jpg

That's that done for now, so lets move onto the input box. Select the text tool on the "Tools" toolbar, and on the menu under the "Properties" tab select "Input Text". (Any formatting changes you can make when you have got the functionality done.) Now type "q" in the variable box shown below.

var.jpg

Putting "q" will tell the search form to add "?q=" to the end of the url that you specify it to go to; which is the next step.

To tell the form where you want the form contents to be directed to, click on your "Search" button and press "F9" to bring up the actions panel. Type:

on(release){
    getURL ("http://google.com/search", "", "GET");
}

Next step, select the grey area surrounding the contents of your frame, and press "F9" again (assuming that you closed it), and type in the following, replacing it with your site's url of course:

sitesearch = "alanedwardes.com";

You now have a fully functional google website search! If like me most of the time, you cant be bothered to follow the steps above and prefer a file to work from, scroll down.

example.fla - 32kb The editable flash source file.

example.swf - 4kb

The working example.

2 Comments

iqbal's Gravatar
1

So nice of you, its very helpful

kunal's Gravatar
2

hello,

it's very very attractive flash script..... thanks.

Add a Comment

05th of November 2006 at 4:35 PM

5 years, 6 months ago

written by Alan Edwardes.

432 words

2 comments so far

feed for comments on this post

rand: Stop Facebook "Like" Email Spam

next: Huh?

prev: Google + YouTube = Advantage?

share:FacebookTwitterRedditdiggStumbleUpondeliciousHacker NewsLinkedIn

add a comment

© 2006 – 2012 Alan Edwardes / code on github
Top