<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; /*在下面的方法中,會發(fā)送RecipeEvent,該事件使得FrontController接收來自服務(wù)器的數(shù)據(jù),我們不需要知道服務(wù)器究竟是從數(shù)據(jù)庫中讀取數(shù)據(jù)還是從其他地方讀取。更多關(guān)于FrontController的信息,請查看21.8小節(jié)。而現(xiàn)在,我們關(guān)心的是視圖和視圖發(fā)送的通知應(yīng)用程序獲取數(shù)據(jù)的事件。另外需要注意的是,CairngormEvent類有一個dispatch方法,用來把它們發(fā)送到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(); }