<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(); }