flex中的动态实现remoteobject
在flex中,一般直接在设计时写remoteobject的话,这个是比较普遍了,但有的时候,需要在AS代码中动态设置
remoteobject,这个比较少见,所以小结学习之:
情景是,当页面加载时,代码新建立一个remoteobject,然后设置其方法和调用参数,最后把调用返回的结果(是JAVA中的一个LIST),绑定到
一个repeater控件中去,下面来看代码:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="firstload()" width="706" height="417">
[Bindable]
private var posArray:ArrayCollection = new ArrayCollection();
private function firstload():void
{
var categoryremote:RemoteObject=new RemoteObject();
categoryremote.destination="categoryservice";
var o:AbstractOperation = categoryremote.getOperation("getCategoriesByPidflex");
o.send(144);
o.addEventListener(ResultEvent.RESULT, resultEvent);
}
//remoteobject返回的list
private function resultEvent(event:ResultEvent):void{
posArray = event.result as ArrayCollection;
r.dataProvider=posArray;
}
private function findAllFaultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultString, "Error");
}
注意用o.send中,包含了要发送的参数, o.addEventListener(ResultEvent.RESULT, resultEvent)中,处理返回的结果事件。
<mx:Repeater id="r">
&
相关文档:
关键词:文件上传,文件下载,FileReference,FileReferenceList,FileFilter
在项目开发过程中,经常会遇到文件上传下载的问题。但在flex中由于安全沙箱的原因,flex程序不能直接访问本地文件。但是flex SDK中提供了FileReference和FileReferenceList两个类,可以通过这两个类来实现,这两个类位于flash.net包中。
一、 ......
1、Subclipse
最近工作中,所有项目都在SVN中进行。由于Flex Builder没有内置SVN支持,很是不便。在编译时,”svn”文件夹会导致一些莫名错误。在编写Flash as时,我现在习惯用Flash Develop,小巧实用,也支持SVN。为了方便,给Flex Builder也装了SVN插件。由于FB基于Eclipse,安装方法都是一样的。
选择 He ......
1、mian.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="HTTPSrv.send();" width="242" height="442">
<mx:Script>
<!--[CDATA[
import mx.rpc.events.ResultEv ......
由于Flex Builder compiler shell有memory leak的问题, 而SDK默认的的 JVM heap size 只有312M,当compile比较大的project容易不够,所以只要修改SDK的JVM参数就可以。
编辑 {Flex SDK}/bin/jvm.config 文件如下。
java.args=-Xmx512m ...
如果还是有Error,可以增加到1024或者更多。 ......
1.flex端
<mx:Button id="upload" label="上传文件" click="ExternalInterface.call('openUpload');"/>
2后台
2.1 openUpload是后台的js脚本(jsp)
function openUpload(){
var url="/OA/service/upload.jsp";
newWin=jscomNewWinOpenByS ......