using System; using System.Collections; namespace oreilly.cookbook.vo { publicclassRecipeVO { publicstring title; public ArrayList ingredients; public ArrayList instructions public RecipeVO(){} } }
using System; using System.Web; using oreilly.cookbook.vo; namespace oreilly.cookbook.service { publicclassRecipeService { public RecipeService() { } public RecipeVO getRecipe() { RecipeVO rec = newRecipeVO(); rec.title = "Apple Pie"; string[] ingredients = {"flour", "sugar", "apples", "eggs", "water"}; rec.ingredients = newArrayList(ingredients); string[] instructions = {"instructions are long", "baking is hard","maybe I'll just buy it at the store"}; rec.instruction = newArrayList(instructions); return rec; } } }
当服务返回时,可以这样访问RecipeVO:
+展开
-XML
<mx:RemoteObjectid="recipeService" destination="fluorine" source="oreilly.cookbook.FlexService" showBusyCursor="true" result="roResult(event)" fault="roFault(event)" /> <mx:Script> <![CDATA[ privatefunction initApp():void { // we have to register the object for the result to be able to properly cast // as the RecipeVO flash.net.registerClassAlias("oreilly.cookbook.vo.RecipeVO", RecipeVO); } publicfunction serviceResult(e:ResultEvent):void { var rec:RecipeVO = (e.result as RecipeVO) } publicfunction serviceFault(e:FaultEvent):void { trace(" Error :: "+(e.message as String)); }