關於flex處理java 實體bean,我也查了好多資料,現在終於搞定,寫一個簡單的例子,分享給大家
高手就不用看了
/*student實體類=java*/
public class Student implements java.io.Serializable{
private String sNo;
private String sName;
get..
set..
}
/*flex as類 Student.as*/
package flexas
{
[Bindable]
[RemoteClass(alias="com.Student")]
public class Student
{
public function Student()
{
}
public var SNo:String;
public var SName:String;
}
}
/*script 我是在mxml裡寫的,當然你也可以抽出來寫出.as檔案*/
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="100%" width="100%" creationComplete="choose()">
<mx:Script>
<![CDATA[
import flexas.Student;
function choose():void{
probiz.getBycode(tt.text);//後台業務方法
probiz.addEventListener(ResultEvent.RESULT,getPro);
}
function getPro(event:ResultEvent):void{
var pt:Student=Student(event.result);
Alert.show(pt.SName);
}
]]>
</mx:Script>
<!--通過RemoteObject和java互動-->
<mx:RemoteObject id="probiz" destination="proBiz"/>
<mx:Text x="47" y="408" text="Text" width="98" height="69" id="tt"/>
</mx:Application>