O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20.6. Views

You need views to allow the user to enter search terms, select categories, and display the results of searches in order to select posts from those results.

Start with the view that will allow users to enter search terms. In the com.FlexBlog.views package create a new component based on HBox. Name it SearchBoxView. Remember to clear the height and width from the creation dialog. Edit the component to match the following:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
    <![CDATA[
    import com.FlexBlog.events.KeyWordSearchEvent;
    ]]>
</mx:Script>
     <mx:TextInput id="searchTerms"/>
     <mx:Button id="searchButton" label="Search" click="new
KeyWordSearchEvent(this.searchTerms.text).dispatch();"/>
</mx:HBox>

This component simply provides a textbox for the user to enter in terms and a button that directly dispatches a KeyWordSearchEvent using the value from the textbox.

Next, create the view that will allow the user to search by category. In the com.FlexBlog.views package create a new component based on VBox. Name it CategorySearchView. Remember to clear the height and width from the creation dialog. Edit the component to match the following:

<?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import com.FlexBlog.valueobjects.CategoryVO; import com.FlexBlog.events.CategorySearchEvent; import com.FlexBlog.models.FlexBlogModel; [Bindable] private var model:FlexBlogModel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required