flex实现读取本地文件
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("a.txt");
private function initComplete():void
{
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
}
private function onComplete(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
if (loader != null)
{
trace(loader.data);
}
else
{
trace("loader is not a URLLoader!");
}
}
之所以要读取本地文件,是因为我没有安装FlexDataService没有发配置WebService的WSDL所以从文本中把它读出来,赋值给WebService的wsdl属性,但是我看FlexDeveloperGuid上有一句话
You configure destinations in the Flex services configuration file
or a file that it includes by reference.
这好像是说可以不用FDS,但是有不知道怎么弄,只好用这个不安全的方法,其实我们可以把字符串加密....呵呵
对了这样写的时候需要注意一点是给WebService的wsdl指定了之后还需要调用一个loadWSDL()方法,要不然不管用哦!
相关文档:
今天做Flex时碰到flex和java交互的乱码问题,使用HTTPService无论是从Flex端传到Java端,还是反过来都乱码。调查了半天,终于搞定了。
以下是解决方案:
1.Flex端传到Java端
Flex端:encodeURIComponent(comment.text)
使用encodeURIComponent把参数转换为 application/x-www ......
自定义类(BroadCastMarquee.as):
package marquee
{
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFiel ......
本文编译后的补丁下载链接 http://download.csdn.net/source/1908278
多模块应用,每加载一个模块都会重复加载模块所使用的RSL,现在增加一个
private static var loadedRSLs:Dictionary = new Dictionary(); 来保存是否已加载
mx.core.RSLListLoader
//////////////// ......