废话不说,直接代码部分代码摘抄自网上,在此想原作者表示感谢
1、服务端 uploadFile.ashx
<%@ WebHandler Language="VB" Class="UploadFile" %>
Imports System
Imports System.Web
Imports System.Web.HttpServerUtility
Imports System.IO
Imports System.Web.HttpRequest
Public Class UploadFile : Implements IHttpHandler
Private m_UploadPath As String = "~\Files\"
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
Dim responses As String = ""
Dim files As HttpFileCollection = context.Request.Files
If files.Count = 0 Then
'Response.Write("请勿直接访问本文件 ......
废话不说,直接代码部分代码摘抄自网上,在此想原作者表示感谢
1、服务端 uploadFile.ashx
<%@ WebHandler Language="VB" Class="UploadFile" %>
Imports System
Imports System.Web
Imports System.Web.HttpServerUtility
Imports System.IO
Imports System.Web.HttpRequest
Public Class UploadFile : Implements IHttpHandler
Private m_UploadPath As String = "~\Files\"
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
Dim responses As String = ""
Dim files As HttpFileCollection = context.Request.Files
If files.Count = 0 Then
'Response.Write("请勿直接访问本文件 ......
flex和C++服务器通信。因为安全沙漏问题,当swf位于A服务器,C++服务器程序位于B服务器时。
这时swf和B服务器建立Socket建立连接会产生跨域问题。
解决方法如下
swf建立socket时会先发起一个请求跨域文件的请求:"<policy-file-request/>"
服务器接收到后发送字符串
<?xml version="1.0"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"\>
<allow-access-from domain="IP地址或*" to-ports="socket打开的端口" />
</cross-domain-policy>
并关闭这个发来跨域请求的端口。
大功告成!
参考:http://hi.baidu.com/cjmxp/blog/item/815fdd88d40e3c93a4c27236.html ......
1.复制内容到系统剪贴板
System.setClipboard(strContent);
2.复制一个ArrayCollection
//dummy solution( well, it works )
var bar:ArrayCollection = new ArrayCollection();
for each ( var i:Object in ac ){
bar.addItem( i );
}
// fantastic ! //
var bar:ListCollectionView = new ListCollectionView( ListCollectionView( ac ).list );
3.打开一个新浏览器窗口
navigateToURL(new URLRequest('http://ntt.cc'), '_blank');
4.刷新浏览器
navigateToURL(new URLRequest("javascript:location.reload();"),"_self")
5.关闭浏览器
navigateToURL(new URLRequest("javascript:window.close()"),"_self");
6.设置Alert 窗口的背景为透明
Alert
{
modalTransparency:0.0;
modalTransparencyBlur:0;
}
7.取随机颜色
lbl.setStyle('color', 0xffffff*Math.random());
8.清除子串左侧空格
publ ......
要在Flex的DataGrid里添加序号列,大体上有两种方法:
设置DataGridColumn的labelFunction。
其大致的思路是,获取到当前DataGrid的dataProvider及当前行的data,调用getItemIndex方法获取到当前的行的序号。
具体可参考 http://wmcai.blog.163.com/blog/static/480242008111115724283/。这种方法比较直观,也很容易想到。
但重用性很差,其生成序号的labeldFunction无法重用。
设置DataGridColumn的ItemRenderer。
即自定义一个itemRenderer来处理序列号的生成。这种方法重用性很高。至于如何生成序号,这里需要些小技巧。
SequenceItemRenderer.as
package com.carnation.component.common
{
import mx.collections.IList;
import mx.controls.Label;
import mx.controls.listClasses.BaseListData;
import mx.controls.listClasses.ListBase;
public class SequenceItemRenderer extends Label
{
public function SequenceItemRenderer()
{
super();
}
// 另一种方法获取dataProvider并调用getItemIndex方法
// override public function set data(value:Object):void{
// super.data = value;
// ......
环境:eclipse 3.5 + tomcat 6.0 + flex builder 3.0 + blazeds-turnkey-3.2.0.3978.zip(adobe网站上下载)
(因为不能放截图所以只能叙述了)
1,新建一个
java web
项目 例名为 :testjava;
2,在此工程中写一个简单的类:
package cn.com;
public class InfoTest {
public String seeHello() {
return "Hello World";
}
}
3,在testjava工程加与flex通信环境:
解压blazeds-turnkey-3.2.0.3978.zip,找到里面的blazeds.war,将它导进testjava工程(右击WebContent>>import...>>File System 选上硬盘中你的blazeds.war地址>>finish)
编辑WEB-INF/flex/remoting-config.xml :
<?xml version="1.0" ......
最近项目需要运用到FLEX,但GOOGLE一下发现可用的资料实在太少了。
找了好久发现google code上在这个还不错,还有很多东西可以好好研究研究
http://code.google.com/p/as3gif/
下面的例子是将动态GIF绑定到SPRITE上
package com.render
{
import flash.display.Sprite;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import mx.core.Application;
import org.bytearray.gif.player.GIFPlayer;
public class SpriteWithBitmap extends Sprite
{
//Pass the source path or url here.
private static const defaultUrl:String = "/consoleweb/console/images/treewait.gif";
public function SpriteWithBitmap(url:String = defaultUrl)
{
loadImg(url);
}
private function loadImg(url:String):void
{
var gifPlayer:GIFPlayer = new GIFPlayer();
var request:URLRequest = new URLRequest(url);
& ......