5/8/11

How to Put a Search Bar on Flash

Add a search bar to your Flash website or Flash blog. Give your users direct access to Web searches without leaving your site. As of fall 2010, AS3 is Flash's latest programming language, and it helps to start off slowly and gain an understanding of a few concepts. With some code, an input text box and button, you can have the power of a search engine like Yahoo! or Google.
    • 1

      Open Flash and click "File," "New" and then "Flash File (ActionScript 3.0)" from the pullout menu.

    • 2

      Click the "Rectangle" tool from the toolbar. While holding down your mouse, drag across the stage to draw a rectangle for your images. Create a button by clicking "Insert" on the main menu and then "New Symbol." Click the "Button" radio button and type in "search_btn" for the name. Click "OK." (See References for the basic steps; this code is changed so it would work in AS3)

    • 3

      Create input text by clicking the "Text" tool on the toolbar and dragging a rectangle where you want your text. Open the properties panel by clicking "Window" from the main menu, clicking "Properties" and then "Properties" again from the pullout menu. Click "Input Text" from the drop-down menu. Type "search_txt" for the instance name.

    • 4

      Click the search button and type "search_btn" for the instance name.

    • 5

      Right-click Frame "1" on the time line and then click "Action" from the pullout menu. Type this code:

      var link:URLRequest=new URLRequest("http://www.google.com/search?q=" + search_txt.text);

      search_btn.addEventListener(MouseEvent.CLICK, onClick);

      function onClick(event:MouseEvent):void

      {

            navigateToURL(link);

      }

    • 6

      Press "Ctrl" and "Enter" on your keyboard to test the movie.

  • No comments: