Let me give a more comprehensive example, first look at the structure of the entire project, server-side use of blazeds, the structure of
The client uses Flex Builder 3 development and the structure follows the Flex Builder 3 standard
Client.mxml for
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml"
layout= "Vertical" >
<mx:remoteobject destination= "HelloService"
Id= "Test1" >
<mx:method name= "Hello"
result= "Sayhelloresult (event)"/>
<mx:method name= "World"
result= "Sayworldresult (event)"/>
<mx:method name= "Getmap"
result= "Getmapresult (event)"/>
<mx:method name= "GetList"
result= "Getlistresult (event)"/>
<mx:method name= "Getset"
result= "Getsetresult (event)"/>
</mx:RemoteObject>
<mx:HBox>
<mx:label text= "Input:"/>
<mx:textinput id= "Inputstr"/>
<mx:button label= "Say hello"
click= "SayHello (event);" />
<mx:button label= "Say World"
click= "Sayworld (event);" />
<mx:button label= "Get Map"
Click= "Test1.getmap ()"/>
<mx:button label= "Get List"
Click= "test1.getlist ()"/>
<mx:button label= "Get Set"
Click= "Test1.getset ()"/>
</mx:HBox>
<mx:HBox>
<mx:label text= "Result:"/>
<mx:textarea id= "Result"/>
</mx:HBox>
<mx:Script>
<!--[cdata[
Import mx.collections.ArrayCollection;
Import mx.rpc.events.FaultEvent;
Import Mx.controls.Alert;
Import mx.rpc.events.ResultEvent;
Import CN. person;
[bindable]
public Var Person:person;
[bindable]
public Var map:arraycollection=null;
function SayHello (event:event): void
{
var Inputvar:string=inputstr.text;
Test1.hello (Inputvar);
}
function Sayworld (event:event): void
{
var Inputvar:string=inputstr.text;
Test1.world (Inputvar);
}
Private Function Sayhelloresult (event:resultevent): void
{
Result.text=event.result.tostring ();
Alert.show (Event.result.toString (), "return result");
}
Private Function Sayworldresult (event:resultevent): void
{
Result.text=event.result.tostring ();
Alert.show (Event.result.toString (), "return result");
}
Private Function Getmapresult (event:resultevent): void
{
for (Var key:string in Event.result)
{
var list:arraycollection=event.result[key] as ArrayCollection;
for (var key1:object in list)
{
Alert.show ("Map Item key is:" + key + "value is:" + key1);
}
}
}
Private Function GetList (): void
{
Test1.getlist ();
}
Private Function Getlistresult (event:resultevent): void
{
var ac:arraycollection=event.result as ArrayCollection;
for (Var i:int=0 i < ac.length; i++)
{
var P1:person=ac.getitemat (i) as person;
Alert.show ("list item name is:" + p1.name+ "\ n Another usage:" +ac.getitemat (i). Name);
}
}
Private Function Getset (): void
{
Test1.getset ();
}
Private Function Getsetresult (event:resultevent): void
{
var ac:arraycollection=event.result as ArrayCollection;
for (Var i:int=0 i < ac.length; i++)
{
var P1:person=ac.getitemat (i) as person;
Alert.show ("Set Item name is:" + p1.name);
}
}
]]-->
</mx:Script>
</mx:Application>
Current 1/2 page
12 Next read the full text