<mx:Canvasxmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"> <mx:Script> <![CDATA[ import oreilly.cookbook.cairngorm.events.RecipeEvent; import oreilly.cookbook.cairngorm.model.Model; /*在下面的方法中,會發送RecipeEvent,該事件使得FrontController接收來自服務器的數據,我們不需要知道服務器究竟是從數據庫中讀取數據還是從其他地方讀取。更多關于FrontController的信息,請查看21.8小節。而現在,我們關心的是視圖和視圖發送的通知應用程序獲取數據的事件。另外需要注意的是,CairngormEvent類有一個dispatch方法,用來把它們發送到Cairngorm EventDispatcher上。這跟通常情況下處理事件的方式不同,需要確保事件被FrontController處理而不是被其他的截獲。*/ privatefunction loadRecipes():void{ var evt:RecipeEvent = newRecipeEvent(RecipeEvent.GET_RECIPE); evt.recipeKeywords= recipeKeywords.text.split("," ); //Note that the CairngormEvent class dispatches itself //This notifies the Cairngorm EventBroadcaster that the event //is being dispatched. This is used to ensure that the Cairngorm architecture //handles the event rather than the flash.events.EventDispatcher evt.dispatch(); }