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

Building the Commands > The Add Item Command

The Add Item Command

Class

AddItemCommand.as

Responsibilities

When the user adds an item in the Timeline or Details components (such as adding a Chapter to a Part, or a Note to a Scene), the AddItemCommand is executed. Based on the type of AppEvent (e.g. AppEvent.ADD_CHAPTER or AppEvent.ADD_NOTE), it will add the appropriate item and select it in the SelectionContext.

  • Extend SimpleCommand

  • Get the AppEvent from the Notification body

  • Retrieve the SelectionContext from its transient Proxy

  • If the type of the AppEvent is ADD_PART, get the selected Story, call its getNewPart() method, then call the SelectionContext’s selectStory() method with null followed by the selected Story, causing the view hierarchy to redraw with the new Part shown


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial