Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

A Tale of Two Views > The Draft Tile

The Draft Tile

UI—The Draft Tile

Figure 4-15. UI—The Draft Tile

Class

DraftTile.mxml

Responsibilities

  • Base on Flex VGroup class

  • Declare a Flex HGroup for padding to exact height of other tiles, since this tile has no children

  • Declare a Flex ToggleButton for selecting the DraftVO

  • Expose a public property for setting the DraftVO to be displayed

  • Clicking the ToggleButton should set the selected SceneVO’s currentDraft and dispatch the appropriate event to select the DraftVO

  • Expose a bindable public property for setting the SelectionContext

  • Provide the displayed DraftTile instances with the SelectionContext object

Collaborations

The DraftTile component knows and controls its direct children: the Flex HGroup and Button components. It also knows the SelectionContext class, the DraftVO class, and the AppEvent class.

The DraftTile component is known only by its parent, the SceneTile component.

Code

<?xml version="1.0" encoding="utf-8"?>
<!-- DRAFT TILE -->
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:component="com.futurescale.sa.view.component.*"
          height="100%" width="100%">
    
    <fx:Script>
        <![CDATA[
            import com.futurescale.sa.model.vo.DraftVO;
            import com.futurescale.sa.model.vo.SceneVO;
            import com.futurescale.sa.view.context.SelectionContext;
            import com.futurescale.sa.view.event.AppEvent;
            
            // Selection context
            [Bindable] public var context:SelectionContext;
            
            // The Draft
            [Bindable] public var draft:DraftVO;

            // Toggle the Draft selection 
            public function selectDraft():void
            {
                context.scene.currentDraft = draft;
                var appEvent:AppEvent = new AppEvent( AppEvent.SELECT_DRAFT );
                appEvent.data = draft;
                appEvent.related = context.scene;
                dispatchEvent(appEvent);
            }

        
    </fx:Script>

    <!-- PADDING GROUP -->
    <s:HGroup width="100%"/>
    
    <!-- DRAFT BUTTON -->
    <s:ToggleButton id="draftButton" click="selectDraft()"
                    selected="{context.draft.uid == draft.uid}"
                    height="100%" width="100%" minWidth="75" minHeight="25"
                    label="{draft.name}"/>
    
</s:VGroup>