- 浏览: 407031 次
- 性别:
- 来自: 济南
最新评论
-
nianshi:
slideDown就是show的滑动效果版本, slideUp ...
Jquery零碎代码收藏 -
nianshi:
以后编写JS代码,少写<div onclick=&quo ...
Jquery零碎代码收藏 -
nianshi:
获取匹配元素相对父元素的偏移var p = $("p ...
Jquery零碎代码收藏 -
nianshi:
获取匹配元素在当前窗口的相对偏移var p = $(" ...
Jquery零碎代码收藏 -
wuchu:
谢谢
Flex 读取XML配置文件总结
下面的实例演示了Flex中的 FileReference 类的基本用法,允许用户从服务器上下载一个文件。这个例子也演示了你可以在
DataGrid组件中显示数据提示(data tips) ,只要把 data grid column 的 showDataTips 属性设置为
true ,然后把 column 的 dataTipField 设置一个值就行了。
在下边的演示中,当用户点击按钮的时候会下载一个 zip 文件 ,然后你可以把鼠标移到 DataGrid 组件的 Type 列上,来看额外的 Event 信息。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
verticalAlign="middle" backgroundColor="white"
creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import flash.net.FileReference;
[Bindable]
[Embed('assets/disk.png')]
private var diskIcon:Class;
[Bindable]
private var arrColl:ArrayCollection;
// 要下载文件的URL
private
const FILE_URL:String =
"http://www.nshen.net/blog/doc/flex/FileReference_download_test/FileReference_download_test.zip";
private var fileRef:FileReference;
private var urlReq:URLRequest;
private function init():void {
// 初始化一个空ArrayCollection
arrColl = new ArrayCollection();
// 以FILE_URL指定的地址建立一个URLRequest
urlReq = new URLRequest(FILE_URL);
// 定义一个FileReference对象,并填加一系列事件监听
fileRef = new FileReference();
fileRef.addEventListener(Event.CANCEL, doEvent);
fileRef.addEventListener(Event.COMPLETE, doEvent);
fileRef.addEventListener(Event.OPEN, doEvent);
fileRef.addEventListener(Event.SELECT, doEvent);
fileRef.addEventListener(HTTPStatusEvent.HTTP_STATUS, doEvent);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, doEvent);
fileRef.addEventListener(ProgressEvent.PROGRESS, doEvent);
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doEvent);
}
private function doEvent(evt:Event):void {
// 取得当前FileReference的引用
var fr:FileReference = evt.currentTarget as FileReference;
// 填加事件顺序和类型到DataGrid组件
arrColl.addItem({data:arrColl.length+1, type:evt.type, eventString:evt.toString()});
try {
// 更新 Model.
fileRefModel.creationDate = fr.creationDate;
fileRefModel.creator = fr.creator;
fileRefModel.modificationDate = fr.modificationDate;
fileRefModel.name = fr.name;
fileRefModel.size = fr.size;
fileRefModel.type = fr.type;
// 显示文本
txt.visible = true;
} catch (err:*) {
// uh oh, an error of sorts.
}
}
private function downloadSourceCodeZip():void {
// 清空现有的 array collection.
arrColl = new ArrayCollection();
// 隐藏文本组件
txt.visible = false;
// 开始下载
fileRef.download(urlReq);
}
private function showAlert(item:Object):void {
Alert.show(item.eventString, item.type);
}
]]>
</mx:Script>
<mx:Model id="fileRefModel">
<file>
<creationDate>{""}</creationDate>
<creator>{""}</creator>
<modificationDate>{""}</modificationDate>
<name>{""}</name>
<size>{""}</size>
<type>{""}</type>
</file>
</mx:Model>
<mx:Button
id="downloadBtn" label="Download example source code" icon="{diskIcon}"
click="downloadSourceCodeZip()" toolTip="{FILE_URL}" height="40" />
<mx:DataGrid
id="debug" dataProvider="{arrColl}" width="{downloadBtn.width}"
rowCount="5" rowHeight="22"
itemClick="showAlert(event.currentTarget.selectedItem)">
<mx:columns>
<mx:DataGridColumn dataField="data" headerText="#" width="20" />
<mx:DataGridColumn dataField="type" headerText="Type" showDataTips="true" dataTipField="eventString" />
</mx:columns>
</mx:DataGrid>
<mx:Text id="txt" condenseWhite="true" visible="false">
<mx:text>
creationDate: {fileRefModel.creationDate}
creator: {fileRefModel.creator}
modificationDate: {fileRefModel.modificationDate}
name: {fileRefModel.name}
size: {fileRefModel.size}
type: {fileRefModel.type}
</mx:text>
</mx:Text>
</mx:Application>
发表评论
-
Flex小记录
2011-02-24 10:18 1259Flex读取XML: <mx:HTTPServic ... -
flex实现滑动显示隐藏效果
2010-12-30 15:30 1540鼠标划过的时候显示菜单栏 ,鼠标移开后隐藏菜单栏。比较常用 ... -
flex DataTimePicker时间控件
2010-12-27 11:54 1290两种DatatimePicker: 1.Datatim ... -
ActionScript 生成伪Guid
2010-12-24 09:52 1164在一个Flash制作的图片上传程序中(使用了FileRefer ... -
Flex中Image组件怎么才能非等比例拉伸图片
2010-12-23 15:49 1477Image组件怎么才能非等比例拉伸图片 设 ... -
Flex中Accordion用法
2010-12-23 11:45 3047<? xml version = & ... -
Flex(替代session过期)实现用户长时间不操作要求重新登录的处理
2010-12-23 11:08 1476flex(替代session过期)用户长时间不操作要求重新登录 ... -
ActionScript 3.0 Socket编程
2010-12-23 09:56 1136在使用ActionScript3.0进行编程 ... -
12个简单易用的flex函数
2010-12-21 10:10 10961.拷贝内容到剪贴板: ... -
Flex自定义控件——Pagebar分页控件
2010-12-20 09:41 5186开发时经常遇到用一个DataGrid分页显示 ... -
Flex资源,很全,很牛!
2010-12-20 09:30 14251、as3ebaylib http://code ... -
Flex 窗体 最大化、最小化实例
2010-12-20 09:28 2676---导入flexMdi.swc (http ... -
在Flex中复制文字到操作系统的剪贴板
2010-12-15 11:18 1200这个实例演示了怎么样使用System. ... -
Flex让Slider控件拖动时显示Tooltip
2010-12-14 16:10 1870格式化与自定义Slider中显示的Tooltip ... -
Flex给Alert加个Icon
2010-12-14 16:05 1254给Alert加个Icon 很简单只要先 Embed 一 ... -
在Flex中用Validator验证数字、字符串、Email、电话号码等
2010-12-14 09:54 4265mx.validators ... -
Flex使用ArrayCollection的filterFunction属性过滤DataGrid
2010-12-14 09:42 1766下面的实例演示了在Flex中怎样使用 ... -
Flex 树形控件(Tree )的使用
2010-12-13 16:24 3435一、树形控件的常用属性 1、dragMoveE ... -
FLEX3中应用CSS完全详解手册(下)
2010-12-13 11:40 843myTabs中的设置 cornerRadiusTab ... -
FLEX3中应用CSS完全详解手册(上)
2010-12-13 11:16 867编辑完这个FLEX下的CSS说明后,我基本已经兵临崩溃 ...
相关推荐
Flex与.NET互操作(五):使用FileReference+HttpHandler实现文件上传/下载 一文的源码的完整工程文件,包含FLEX客户端和 ASP.NET服务端源码! 在VS2010和FLash builder4 中运行!
Flex Builder 3 下载安装与项目创建详细说明 Flex中利用FileReference类下载文件的例子| 中文Flex例子
Flex与.NET互操作 使用FileReference+HttpHandler实现文件上传/下载
在项目开发过程中,经常会遇到文件上传下载的...但在flex中由于安全沙箱的原因flex程序不能直接访问本地文件,但是flex SDK中提供了FileReference和FileReferenceList两个类,可以通过这两个类来实现文件的上传下载。
FLEXd多文件上传,上传前MD5验证允许那些文件可以上传
//ItemDate单文件大小限制,-1表示不限制,默认值为30M param.TotalDate = (this.parameters.TotalDate == undefined || this.parameters.TotalDate == "") ? -1 : this.parameters.TotalDate;//TotalDate总...
完成的文件上传功能。使用FileReference类实现。还有多文件上传
请使用“flex 文件上传下载完整代码(修正版)”http://download.csdn.net/source/1815266
FileReferenceList 类或者FileReference 一个是多个上传一个是单个上传。用这2个类通过Java实现文件图片上传。
flex语言编写的,把xml内容存成xml文件保存到指定的位置!
在ActionScript中使用XML的示例:从Internet加载RSS数据 第章:使用本机JSON功能 JSONAPI概述 定义自定义JSON行为 第章:处理事件 事件处理基础知识 ActionScript事件处理与早期版本事件处理的不同之处 事件流 事件...
鉴于adobe并没有提供FileReference对浏览的文件的完整路径的接口。只能采用JS和fileinput控件来获取本地路径了。