flex 对话框进度条,加载框等等

flex&ProgressBar&进度条
&?xml version="1.0"
encoding="utf-8"?&
&mx:Application xmlns:mx=""&
&&mx:Script&
&&&![CDATA[
&&&private var
j:Number = 10;
&&&private
function addProgress():void{
&&&&&bar.setProgress(j,100);
&&&&&bar.label
= "正在加载loading..."+ j +"%";
&&/mx:Script&
&&mx:ProgressBar minimum="10"
maximum="100" label="正在加载loading... 0%" fontSize="12"
direction="right" id="bar" themeColor="#ee1122" mode="manual" /&
&&mx:Button label="按钮"
fontSize="12" click="addProgress()" /&
&/mx:Application&
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。0 ? parseInt(this.value) : 1) + '.html';}else{window.location='showtopic.aspx?keywordsurl=23382&page=' + (parseInt(this.value) > 0 ? parseInt(this.value) : 1);}}if((event.keyCode >= 48 && event.keyCode / 27
最近在做大文件上传项目时碰到了很多问题。基于.net的大文件上传组件网上是大把的有。但这些组件基本上都是基于HttpModule模式的,大部分都存在一个致命的问题:严重消耗内存。最后没办法,只好采用Flash的FileReference模式去上传。具体我也不是很明白,大家可自己研究。 600) this.width = 600;attachimg(this, 'load');" onmouseover="attachimginfo(this, 'attach_15550', 1);attachimg(this, 'mouseover')" onclick="zoom(this);" onmouseout="attachimginfo(this, 'attach_15550', 0, event)" style="CURSOR:"
/>() 14:07:32展开下面的代码看吧,第一次使用代码模式,有点问题一、CS相应源码如下:import flash.net.FileR
import flash.net.URLR
import flash.net.FileF
import flash.display.S
import flash.events.*;
var fileRef = new FileReference();
var fileListener = new Object();
var totalBytes:Number = 0;
var uploadedBytes:Number = 0;
//从外部获取也许上传的文件类型
var acceptFileType:String = getFlashVars(&acceptFileType&);
//设置上传完毕后执行的js脚本
var comJsFun:String=getFlashVars(&ComJsFun&);
//this.tbFilePath.text = comJsF
var uploadURL:URLRequest = new URLRequest();
var xmlRequest:URLRequest = new URLRequest();
var xmlLoader:URLLoader = new URLLoader();
//初始化系统
function init() {
& & this.mcWaterStyle.visible =
& & this.mcFilePlayer.visible =
& & this.progressBar.visible =
& & //设置按钮文字大小,默认的字体和大小有点难看。
& & var myFormat = new TextFormat();
& & myFormat.size = 12;
& & this.btBrowser.setStyle(&textFormat&, myFormat);
& & this.btUpload.setStyle(&textFormat&, myFormat);
& & this.tbFilePath.setStyle(&textFormat&, myFormat);
& & this.mcWaterStyle.style0.setStyle(&textFormat&, myFormat);
& & this.mcWaterStyle.style1.setStyle(&textFormat&, myFormat);
& & this.mcWaterStyle.style2.setStyle(&textFormat&, myFormat);
& & this.uploadInfo.setStyle(&textFormat&, myFormat);
//如果从FlashVars获取的参数acceptFileType(限定上传文件类型)无值,那么访问相应的XML(上传文件类型配置)
& & if(acceptFileType==&&){
& & & & //从外部获取上传附加的文件类型。
& & & & xmlRequest = new URLRequest(&/XML/Setting_Article.xml&);
& & & & xmlLoader.load(xmlRequest);
& & & & xmlLoader.PLETE,loaderHandler);
//按钮事件
this.btBrowser.addEventListener(MouseEvent.CLICK, browseHandler);
this.btUpload.addEventListener(MouseEvent.CLICK, UploadHandler);
fileRef.addEventListener(Event.SELECT,selectHandler);//选择文件
fileRef.addEventListener(Event.CANCEL, cancelHandler);//上传过程中取消事件
fileRef.addEventListener(Event.OPEN, openHandler);//开始上传事件
fileRef.PLETE, completeHandler);//上传完毕事件
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler)//上传数据完毕事件,有点迷惑PLETE跟DataEvent.UPLOAD_COMPLETE_DATA的区别
fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);//上传过程事件,相应的进度条代码在这里了
//监听上传过程可能出错的事件
fileRef.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
//浏览按钮事件
function browseHandler(event:MouseEvent):void {
& & fileRef.browse(browseGetTypes());
function browseGetTypes():Array {
& & var allTypes:Array = new Array(browseGetFileTypeFilter());
& & return allT
function browseGetFileTypeFilter():FileFilter {
& & if(acceptFileType!=&&){
& & & & var arr = acceptFileType.split(&|&);
& & & & var FileExtension = &&;
& & & & for(var i=0;i&arr.i++){
& & & & & & if (arr == &&)
& & & & & & & &
& & & & & & if(i==0)
& & & & & & & & FileExtension = &*.&+
& & & & & & else
& & & & & & & & FileExtension = FileExtension+&;*.&+
& & & & return new FileFilter(&文件格式(&+FileExtension+&)&, &&+FileExtension+&&);
& & }else{
& & & & return new FileFilter(&所有文件(*.*)&,&*.*&);
& & //return new FileFilter(&所有文件(*.*)&,&*.*&);
//加载上传配置事件
function loaderHandler(event:Event):void {
& & var myXML:XML = new XML(xmlLoader.data);
& & //myXML = XML();
& & acceptFileType = myXML.child(&Upload&).ContontFileS
& & trace(&--&+myXML.child(&Upload&).ContontFileStyle+&--&);
& & if(this.uploadInfo.text==&&)
& & & & this.uploadInfo.text = &允许的格式:&+myXML.child(&Upload&).ContontFileS
//选择文件事件
function selectHandler(event:Event):void{
this.uploadInfo.text = &&;
this.mcWaterStyle.visible =
this.mcFilePlayer.visible =
if (fileRef.size & 0){
totalBytes = fileRef.
this.tbFilePath.text =& fileRef.name+ &[& + this.getSizeType(totalBytes) + &]&;
var fileExtName = fileRef.name.substring(fileRef.name.lastIndexOf(&.&)+1);
switch(fileExtName.toLowerCase()){
& & & & & &
case &jpg&:
& & & & & &
case &jpeg&:
& & & & & &
case &gif&:
& & & & & &
case &bmp&:
& & & & & & & &
this.mcWaterStyle.visible =
& & & & & & & &
& & & & & &
case &flv&:
& & & & & & & &
this.mcFilePlayer.visible =
& & & & & & & &
this.mcFilePlayer.mcWidth.text = 410;
& & & & & & & &
this.mcFilePlayer.mcHeight.text = 370;
& & & & & & & &
& & & & & &
case &swf&:
& & & & & & & &
this.mcFilePlayer.visible =
& & & & & & & &
this.mcFilePlayer.mcWidth.text = 550;
& & & & & & & &
this.mcFilePlayer.mcHeight.text = 400;
& & & & & & & &
& & & & & &
case &rm&:
& & & & & &
case &rmvb&:
& & & & & &
case &mp3&:
& & & & & &
case &avi&:
& & & & & &
case &mpg&:
& & & & & &
case &mpeg&:
& & & & & &
case &asf&:
& & & & & &
case &wmv&:
& & & & & &
case &wma&:
& & & & & & & &
this.mcFilePlayer.visible =
& & & & & & & &
this.mcFilePlayer.mcWidth.text = 550;
& & & & & & & &
this.mcFilePlayer.mcHeight.text = 400;
& & & & & & & &
& & & & & &
& & & & & & & &
this.mcWaterStyle.visible =
& & & & & & & &
this.mcFilePlayer.visible =
& & & & & & & &
& & }else{
this.uploadInfo.text = &错误:您没有选择文件!&;
//上传过程中取消
function cancelHandler(event:Event):void{
& & this.progressBar.visible =
//当上载或下载操作开始时
function openHandler(event:Event):void{
& & this.tbFilePath.visible =
& & this.mcWaterStyle.visible =
& & this.mcFilePlayer.visible =
& & this.btBrowser.visible =
& & this.btUpload.label = &取消&;
& & this.progressBar.visible =
function UploadHandler(event:MouseEvent):void{
& & if (this.btUpload.label==&上传&){
& & & & var WaterMarkStyleP:String = &&;
& & & & if(this.mcWaterStyle.style0.selected == true)
& & & & & & WaterMarkStyleP = &0&;
& & & & else if(this.mcWaterStyle.style1.selected == true)
& & & & & & WaterMarkStyleP = &1&;
& & & & else if(this.mcWaterStyle.style2.selected == true)
& & & & & & WaterMarkStyleP = &2&;
& & & & var mcFilePlayerP:String=&&width=&+this.mcFilePlayer.mcW
& & & & mcFilePlayerP += &&height=&+this.mcFilePlayer.mcH
& & & & if(this.mcFilePlayer.mcAutoYes.selected == true)
& & & & & & mcFilePlayerP += &&auto=true&;
& & & & else if(this.mcFilePlayer.mcAutoNo.selected == true)
& & & & & & mcFilePlayerP += &&auto=false&;
& & & & & &
& & & & uploadURL.url=&Upload_File_SWF.aspx?WaterMarkStyle=&+WaterMarkStyleP+mcFilePlayerP;
& & & & fileRef.upload(uploadURL);//此为采用aspx默认方式进行上传的文件地址。如:Upload_File_SWF.aspx此页面我在上传完毕后,直接进行Response.Write(&true&);那么Flash可在uploadCompleteDataHandler后可后去到true这个数据。以便你进行操作。
& & }else if(this.btUpload.label==&取消&){
& & & & this.tbFilePath.visible =
& & & & this.mcWaterStyle.visible =
& & & & this.mcFilePlayer.visible =
& & & & this.btBrowser.visible =
& & & & this.btUpload.label = &上传&;
& & & & this.progressBar.visible =
& & & & this.uploadInfo.text=&&;
& & }else if(this.btUpload.label==&重新上传&){
& & & & this.tbFilePath.visible =
& & & & this.mcWaterStyle.visible =
& & & & this.mcFilePlayer.visible =
& & & & this.btBrowser.visible =
& & & & this.btUpload.label = &上传&;
& & & & this.progressBar.visible =
//在文件上载或下载操作期间定期调用
function progressHandler(event:ProgressEvent):void{
& & //var fileRef:FileReference = FileReference(event.target);
& & if(event.bytesLoaded==event.bytesTotal){
& & & & this.uploadInfo.text= &正在转移数据,请稍后--&+getSizeType(event.bytesLoaded)+&/&+getSizeType(event.bytesTotal);
& & }else{
& & & & this.progressBar.mcMask.width = (event.bytesLoaded/event.bytesTotal)*this.progressBar.mcLoaded.
& & & & this.uploadInfo.text=&上传文件中,请等待--&+getSizeType(event.bytesLoaded)+&/&+getSizeType(event.bytesTotal);
function completeHandler(event:Event):void {
& & //trace(&completeHandler: & + event);
& & this.tbFilePath.visible =
& & this.tbFilePath.text = &&;
& & this.mcWaterStyle.visible =
& & this.mcFilePlayer.visible =
& & this.btBrowser.visible =
& & this.btUpload.label = &上传&;
& & this.progressBar.visible =
& & //this.uploadInfo.text = &上传成功!&;
function uploadCompleteDataHandler(event:DataEvent):void {
& & if(event.data.indexOf(&|&)!=-1){
& & & & var fileInfoArr = event.data.split(&|&);
& & & & if(fileInfoArr[0].toLowerCase()==&true&){
& & & & & & this.uploadInfo.text = &上传成功:&+fileInfoArr[1]+&!&;
& & & & & & if(comJsFun!=&&){
& & & & & & & & //ExternalInterface.call(&UploadForEditor&,&hh&);
& & & & & & & & ExternalInterface.call(&UploadForEditor&,event.data.replace(&true|&,&&));
& & & & & & & & //this.tbFilePath.text = event.
& & & & & & }
& & & & }else{
& & & & & & this.uploadInfo.text = &上传失败:&+EncodeUtf8(fileInfoArr[1])+&!&;
& & trace(&uploadCompleteData: & + event.data);
//错误事件
function httpStatusHandler(event:HTTPStatusEvent):void {
trace(&httpStatusHandler: & + event);
this.mcWaterStyle.visible =
this.mcFilePlayer.visible =
this.uploadInfo.text=&HTTP错误: & +&
function ioErrorHandler(event:IOErrorEvent):void {
trace(&ioErrorHandler: & + event);
this.mcWaterStyle.visible =
this.mcFilePlayer.visible =
this.uploadInfo.text=&IO错误: & +&
function securityErrorHandler(event:SecurityErrorEvent):void {
trace(&openHandler: & + event);
this.mcWaterStyle.visible =
this.mcFilePlayer.visible =
this.uploadInfo.text=&IO安全设置错误: & +&
/**//*--------------------以下为常用函数-------------
---------------------------------------------*/
//处理文件大小表示方法
function getSizeType(s)
& & var danwei = [&Byte&,&KB&,&MB&,&GB& ];
& & var d = 0;
& & while ( s &= 900 )
& & & & s = Math.round(s*100/;
& & & & d++;
& & return s+danwei[d];
function getFlashVars(parName){
& & var parValue:String=stage.loaderInfo.parameters[parName];
& & if(parValue==null)
return &&;
return parV
//转换乱码
function EncodeUtf8(str : String):String {
& & var oriByteArr : ByteArray = new ByteArray();
& & oriByteArr.writeUTFBytes(str);
& & var tempByteArr : ByteArray = new ByteArray();
& & for (var i = 0; i&oriByteArr. i++) {
& & & & if (oriByteArr == 194) {
& & & & & & tempByteArr.writeByte(oriByteArr[i+1]);
& & & & & & i++;
& & & & } else if (oriByteArr == 195) {
& & & & & & tempByteArr.writeByte(oriByteArr[i+1] + 64);
& & & & & & i++;
& & & & } else {
& & & & & & tempByteArr.writeByte(oriByteArr);
& & tempByteArr.position = 0;
& & return tempByteArr.readMultiByte(tempByteArr.bytesAvailable,&chinese&);
& & //return tempByteArr.readMultiByte(tempByteArr.bytesAvailable,&chinese&);
复制代码二、相应的上传文件代码(.net)using S
using System.D
using System.C
using System.C
using System.W
using System.Web.S
using System.Web.UI;
using System.Web.UI.WebC
using System.Web.UI.WebControls.WebP
using System.Web.UI.HtmlC
using System.IO;
using System.D
using System.Drawing.I
namespace TT.WebManager.Web.Admin.Article
& & public partial class Upload_File_SWF : System.Web.UI.Page
& & & & string AppPath = &&;
& & & & string FileURL = &&;//文件网络地址
& & & & string FileURL2 = &&;//文件网络地址,如果加了水印
& & & & string FileAppPath = &&;
& & & & string FileAppPath2 = &&;
& & & & string sFilePathName = &&;
& & & & string sFileName = &&;
& & & & int FileSize = 0;
& & & & string FileExtName = &&;
& & & & int WaterMarkStyle = 0;
& & & & string FileAuto = &true&;
& & & & int FileWidth = 0;
& & & & int FileHeigth = 0;
& & & & protected void Page_Load(object sender, EventArgs e)
& & & & & & TT.WebManager.BLL.Setting bll = new TT.WebManager.BLL.Setting();
& & & & & & bll.Init(false);
& & & & & & AppPath = System.Web.HttpContext.Current.Request.PhysicalApplicationP
& & & & & & WaterMarkStyle = Methods.Req.GetInt(&WaterMarkStyle&, 0);
& & & & & & FileWidth = Methods.Req.GetInt(&Width&,550);
& & & & & & FileHeigth = Methods.Req.GetInt(&Heigth&, 400);
& & & & & & FileAuto = Methods.Req.GetString(&Auto&);
& & & & & & try
& & & & & & {
& & & & & & & & HttpPostedFile postedFile = Request.Files[&Filedata&];
& & & & & & & & sFilePathName = postedFile.FileN
& & & & & & & & FileSize = postedFile.ContentL& //===========获取文件的大小
& & & & & & & & if (FileSize &= 0)
& & & & & & & & {
& & & & & & & & & & Response.Clear();
& & & & & & & & & & Response.Write(&false|您没有选择文件!&);
& & & & & & & & & & Response.End();
& & & & & & & & }
& & & & & & & & else
& & & & & & & & {
& & & & & & & & & & sFileName = sFilePathName.Substring(sFilePathName.LastIndexOf(&\\&) + 1);
& & & & & & & & & & FileExtName = sFilePathName.Substring(sFilePathName.LastIndexOf(&.&) + 1);
& & & & & & & & & & if (IsValidFileType(FileExtName) == false)
& & & & & & & & & & {
& & & & & & & & & & & & Response.Clear();
& & & & & & & & & & & & Response.Write(&false|系统禁止上传此格式的文件!&);
& & & & & & & & & & & & Response.End();
& & & & & & & & & & }
& & & & & & & & & & else
& & & & & & & & & & {
& & & & & & & & & & & & GotoUploadFile(postedFile);
& & & & & & & & & & }
& & & & & & & & }
& & & & & & }
& & & & & & catch { }
& & & & & &
& & & & protected void GotoUploadFile(HttpPostedFile postedFile)
& & & & & & string NewFileName = DateTime.Now.ToString(&yyyyMMddhhmmss&) + FileSize + &.& + FileExtN
& & & & & & string NewFileName2 = DateTime.Now.ToString(&yyyyMMddhhmmss&) + FileSize + &_1.& + FileExtN
& & & & & & string NewFilePath = &&;
& & & & & & if (Model.Article.Setting.Upload_SortFile == true)
& & & & & & {
& & & & & & & & if (Model.Article.Setting.Upload_FolderStyle != &&)
& & & & & & & & {
& & & & & & & & & & FileURL = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + FileExtName + &/& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle) + &/& + NewFileN
& & & & & & & & & & FileURL2 = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + FileExtName + &/& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle) + &/& + NewFileName2;
& & & & & & & & & & NewFilePath = AppPath + Model.Article.Setting.Upload_Folder.Replace(&/&, &\\&) + &\\& + FileExtName + &\\& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle).Replace(&/&, &\\&);
& & & & & & & & }
& & & & & & & & else
& & & & & & & & {
& & & & & & & & & & FileURL = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + FileExtName + &/& + NewFileN
& & & & & & & & & & FileURL2 = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + FileExtName + &/& + NewFileName2;
& & & & & & & & & & NewFilePath = AppPath + Model.Article.Setting.Upload_Folder.Replace(&/&, &\\&) + &\\& + FileExtN
& & & & & & & & }
& & & & & & }
& & & & & & else
& & & & & & {
& & & & & & & & if (Model.Article.Setting.Upload_FolderStyle != &&)
& & & & & & & & {
& & & & & & & & & & FileURL = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle) + &/& + NewFileN
& & & & & & & & & & FileURL2 = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle) + &/& + NewFileName2;
& & & & & & & & & & NewFilePath = AppPath + Model.Article.Setting.Upload_Folder.Replace(&/&, &\\&) + &\\& + DateTime.Now.ToString(Model.Article.Setting.Upload_FolderStyle).Replace(&/&, &\\&);
& & & & & & & & }
& & & & & & & & else
& & & & & & & & {
& & & & & & & & & & FileURL = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + NewFileN
& & & & & & & & & & FileURL2 = Model.Article.Setting.Upload_Prefix + Model.Article.Setting.Upload_Folder + &/& + NewFileName2;
& & & & & & & & & & NewFilePath = AppPath + Model.Article.Setting.Upload_Folder.Replace(&/&, &\\&);
& & & & & & & & }
& & & & & & }
& & & & & & TT.WebManager.Methods.IIOO.CreateDirectory(NewFilePath);
& & & & & & FileAppPath = NewFilePath + &\\& + NewFileN
& & & & & & FileAppPath2 = NewFilePath + &\\& + NewFileName2;
& & & & & & postedFile.SaveAs(FileAppPath);
& & & & & & switch (FileExtName.ToLower())
& & & & & & {
& & & & & & & & case &jpg&:
& & & & & & & & case &jpeg&:
& & & & & & & & case &gif&:
& & & & & & & & case &bmp&:
& & & & & & & & case &png&:
& & & & & & & & & & //==========生成水印=============
& & & & & & & & & & switch (WaterMarkStyle)
& & & & & & & & & & {
& & & & & & & & & & & & case 1:
& & & & & & & & & & & & & & CreateWeaterText(FileAppPath, FileAppPath2, Model.Article.Setting.WaterMark_Text, FileExtName);
& & & & & & & & & & & & & & FileURL = FileURL2;
& & & & & & & & & & & & & &
& & & & & & & & & & & & case 2:
& & & & & & & & & & & & & & CreateWeaterPicture(FileAppPath, FileAppPath2, Server.MapPath(Model.Article.Setting.WaterMark_Picture), FileExtName);
& & & & & & & & & & & & & & FileURL = FileURL2;
& & & & & & & & & & & & & &
& & & & & & & & & & & & default:
& & & & & & & & & & & & & &
& & & & & & & & & & }
& & & & & & & & & &
& & & & & & }
& & & & & & string ReturnString = sFileName + &|& + FileURL + &|& + FileWidth + &|& + FileHeigth + &|& + FileA
& & & & & & Response.Clear();
& & & & & & Response.Write(&true|&+ReturnString);
& & & & & & Response.End();
& & & & private void CreateWeaterText(string paraOldFileName, string paraNewsFileName, string AddText, string FileExtensionName)
& & & & & & System.Drawing.Image image = System.Drawing.Image.FromFile(paraOldFileName);
& & & & & & System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
& & & & & & //文字抗锯齿
& & & & & & g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiA
& & & & & & g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQ
& & & & & & g.CompositingQuality = System.positingQuality.HighQ
& & & & & & g.DrawImage(image, 0, 0, image.Width, image.Height);
& & & & & & //Font font = new Font(&黑体&, 14, FontStyle.Bold);
& & & & & & //Brush b = new SolidBrush(Color.Yellow);
& & & & & & Font font = new Font(Model.Article.Setting.WaterMark_FontFamily, Model.Article.Setting.WaterMark_FontSize, FontStyle.Bold);
& & & & & & Brush b = new SolidBrush(Methods.TypeParse.StrToColor(Model.Article.Setting.WaterMark_FontColor));
& & & & & & int Xpos = 0;
& & & & & & int Ypos = 0;
& & & & & & SizeF crsize = new SizeF();
& & & & & & crsize = g.MeasureString(AddText, font);
& & & & & & int crsize_With = Convert.ToInt32(crsize.Width);
& & & & & & int crsize_Height = Convert.ToInt32(crsize.Height);
& & & & & & int WaterMark_xPos = 10;
& & & & & & int WaterMark_yPos = 10;
& & & & & & switch (Model.Article.Setting.WaterMark_Position)//==========从图片的左上角开始算起(0,0)
& & & & & & {
& & & & & & & & case 1:
& & & & & & & & & & Xpos = WaterMark_xP
& & & & & & & & & & Ypos = WaterMark_yP
& & & & & & & & & &
& & & & & & & & case 2:
& & & & & & & & & & Xpos = image.Width - (crsize_With + WaterMark_xPos);
& & & & & & & & & & Ypos = WaterMark_yP
& & & & & & & & & &
& & & & & & & & case 3:
& & & & & & & & & & Xpos = WaterMark_xP
& & & & & & & & & & Ypos = image.Height - (crsize_Height + WaterMark_yPos);
& & & & & & & & & &
& & & & & & & & case 4:
& & & & & & & & & & Xpos = image.Width - (crsize_With + WaterMark_xPos);
& & & & & & & & & & Ypos = image.Height - (crsize_Height + WaterMark_yPos);
& & & & & & & & & &
& & & & & & }
& & & & & & //画阴影
& & & & & & PointF pt = new PointF(0, 0);
& & & & & & System.Drawing.Brush TransparentBrush0 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(50, System.Drawing.Color.Black));
& & & & & & System.Drawing.Brush TransparentBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(20, System.Drawing.Color.Black));
& & & & & & g.DrawString(AddText, font, TransparentBrush0, Xpos, Ypos + 1);
& & & & & & g.DrawString(AddText, font, TransparentBrush0, Xpos + 1, Ypos);
& & & & & & g.DrawString(AddText, font, TransparentBrush1, Xpos + 1, Ypos + 1);
& & & & & & g.DrawString(AddText, font, TransparentBrush1, Xpos, Ypos + 2);
& & & & & & g.DrawString(AddText, font, TransparentBrush1, Xpos + 2, Ypos);
& & & & & & TransparentBrush0.Dispose();
& & & & & & TransparentBrush1.Dispose();
& & & & & & g.DrawString(AddText, font, b, Xpos, Ypos);
& & & & & & switch (FileExtensionName.ToLower())
& & & & & & {
& & & & & & & & case &jpg&:
& & & & & & & & case &jpeg&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
& & & & & & & & & &
& & & & & & & & case &gif&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
& & & & & & & & & &
& & & & & & & & case &bmp&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);
& & & & & & & & & &
& & & & & & & & case &png&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
& & & & & & & & & &
& & & & & & }
& & & & & & g.Dispose();
& & & & & & image.Save(paraNewsFileName);
& & & & & & image.Dispose();
& & & & & & Response.Clear();
& & & & & & if (File.Exists(paraOldFileName) == true)
& & & & & & {
& & & & & & & & File.Delete(paraOldFileName);
& & & & & & }
& & & & private void CreateWeaterPicture(string paraOldFileName, string paraNewsFileName, string AddPicture, string FileExtensionName)
& & & & & & System.Drawing.Image image = System.Drawing.Image.FromFile(paraOldFileName);
& & & & & & System.Drawing.Image copyImage = System.Drawing.Image.FromFile(AddPicture);
& & & & & & ImageAttributes imageAttributes = new ImageAttributes();
& & & & & & ColorMap colorMap = new ColorMap();
& & & & & & colorMap.OldColor = Color.FromArgb(200, 0, 200, 0);
& & & & & & colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
& & & & & & ColorMap[] remapTable = { colorMap };
& & & & & & imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
& & & & & & float[][] colorMatrixElements = {
& & & & & & & & & & & & & & & & & & & & & & & & new float[] {1.0f,& 0.0f,& 0.0f,& 0.0f, 0.0f},
& & & & & & & & & & & & & & & & & & & & & & & & new float[] {0.0f,& 1.0f,& 0.0f,& 0.0f, 0.0f},
& & & & & & & & & & & & & & & & & & & & & & & & new float[] {0.0f,& 0.0f,& 1.0f,& 0.0f, 0.0f},
& & & & & & & & & & & & & & & & & & & & & & & & new float[] {0.0f,& 0.0f,& 0.0f,& Model.Article.Setting.WaterMark_Transparency, 0.0f},
& & & & & & & & & & & & & & & & & & & & & & & & new float[] {0.0f,& 0.0f,& 0.0f,& 0.0f, 1.0f}
& & & & & & & & & & & & & & & & & & & & & & };
& & & & & & ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
& & & & & & imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
& & & & & & Graphics g = Graphics.FromImage(image);
& & & & & & //PointF pt = new PointF(0, 0);
& & & & & & //System.Drawing.Brush TransparentBrush0 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(50, System.Drawing.Color.));
& & & & & & //System.Drawing.Brush TransparentBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(20, System.Drawing.Color.Black));
& & & & & & //g.DrawString(AddText, font, TransparentBrush0, pt.X, pt.Y + 1);
& & & & & & //g.DrawString(AddText, font, TransparentBrush0, pt.X + 1, pt.Y);
& & & & & & //g.DrawString(AddText, font, TransparentBrush1, pt.X + 1, pt.Y + 1);
& & & & & & //g.DrawString(AddText, font, TransparentBrush1, pt.X, pt.Y + 2);
& & & & & & //g.DrawString(AddText, font, TransparentBrush1, pt.X + 2, pt.Y);
& & & & & & //TransparentBrush0.Dispose();
& & & & & & //TransparentBrush1.Dispose();
& & & & & & //设定合成图像的质量
& & & & & & g.CompositingQuality = System.positingQuality.HighQ
& & & & & & //设置高质量插值法
& & & & & & g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.H
& & & & & & //设置高质量,低速度呈现平滑程度
& & & & & & g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQ
& & & & & & int xPos = image.Width - copyImage.Width - 10;
& & & & & & int yPos = image.Height - copyImage.Height - 10;
& & & & & & switch (Model.Article.Setting.WaterMark_Position)//==========从图片的左上角开始算起(0,0)
& & & & & & {
& & & & & & & & case 1:
& & & & & & & & & & xPos = 10;
& & & & & & & & & & yPos = 10;
& & & & & & & & & &
& & & & & & & & case 2:
& & & & & & & & & & xPos = image.Width - copyImage.Width - 10;
& & & & & & & & & & yPos = 10;
& & & & & & & & & &
& & & & & & & & case 3:
& & & & & & & & & & xPos = 10;
& & & & & & & & & & yPos = image.Height - copyImage.Height - 10;
& & & & & & & & & &
& & & & & & & & case 4:
& & & & & & & & & & xPos = image.Width - copyImage.Width - 10;
& & & & & & & & & & yPos = image.Height - copyImage.Height - 10;
& & & & & & & & & &
& & & & & & }
& & & & & & g.DrawImage(copyImage, new Rectangle(xPos, yPos, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel, imageAttributes);
& & & & & & switch (FileExtensionName.ToLower())
& & & & & & {
& & & & & & & & case &jpg&:
& & & & & & & & case &jpeg&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
& & & & & & & & & &
& & & & & & & & case &gif&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
& & & & & & & & & &
& & & & & & & & case &bmp&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);
& & & & & & & & & &
& & & & & & & & case &png&:
& & & & & & & & & & image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
& & & & & & & & & &
& & & & & & }
& & & & & & g.Dispose();
& & & & & & image.Save(paraNewsFileName);
& & & & & & image.Dispose();
& & & & & & imageAttributes.Dispose();
& & & & & & Response.Clear();
& & & & & & if (File.Exists(paraOldFileName) == true)
& & & & & & {
& & & & & & & & File.Delete(paraOldFileName);
& & & & & & }
& & & & & & // return paraNewsFileN
& & & & protected bool IsValidFileType(string ExtName)
& & & & & & if (Model.Article.Setting.Upload_ContontFileStyle.Trim() == &&)
& & & & & & & &
& & & & & & string[] AcceptedFileTypes = Model.Article.Setting.Upload_ContontFileStyle.Split(new char[] { '|' });
& & & & & & for (int i = 0; i & AcceptedFileTypes.L i++)
& & & & & & {
& & & & & & & & if (ExtName.ToLower() == AcceptedFileTypes.ToLower())
& & & & & & & & {
& & & & & & & & & &
& & & & & & & & }
& & & & & & }
& & & & & &
复制代码三、相应的aspx页面代码&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&
& &title&FLASH 上传测试&/title&
& &meta http-equiv=&content-type& content=&text/ charset=gb2312& /&
& &link href=&../images/style.css& rel=&stylesheet& type=&text/css& /&
& &script language=&javascript&&AC_FL_RunContent = 0;&/script&
& &script src=&../javascript/AC_RunActiveContent.js& language=&javascript&&&/script&
&!--影片中使用的 URL--&
&!--影片中使用的文本--&
&!-- saved from url=(0013)about:internet --&
&script language=&javascript&&
& & if (AC_FL_RunContent == 0) {
& & & & alert(&此页需要 AC_RunActiveContent.js&);
& & } else {
& & & & AC_FL_RunContent(
& & & & & & 'codebase', '/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
& & & & & & 'width', '400',
& & & & & & 'height', '56',
& & & & & & 'src', '../SWFUpload/SWFFileUpload',
& & & & & & 'quality', 'high',
& & & & & & 'pluginspage', '/go/getflashplayer',
& & & & & & 'align', 'middle',
& & & & & & 'play', 'true',
& & & & & & 'loop', 'true',
& & & & & & 'scale', 'showall',
& & & & & & 'wmode', 'window',
& & & & & & 'devicefont', 'false',
& & & & & & 'id', 'SWFFileUpload',
& & & & & & 'bgcolor', '#ffffff',
& & & & & & 'name', 'SWFFileUpload',
& & & & & & 'menu', 'true',
& & & & & & 'allowFullScreen', 'false',
& & & & & & 'allowScriptAccess','sameDomain',
& & & & & & 'movie', '../SWFUpload/SWFFileUpload',
& & & & & & 'salign', '',
& & & & & & 'FlashVars','ComJsFun=UploadForEditor'
& & & & & & ); //end AC code
//src和movie属性为Flash文件地址,请勿写.swf后缀名
//FlashVars为给Flash设置的参数。
&noscript&
& & &object classid=&clsid:d27cdb6e-ae6d-11cf-96b8-& codebase=&/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0& width=&400& height=&56& id=&SWFFileUpload& align=&middle&&
& & &param name=&allowScriptAccess& value=&sameDomain& /&
& & &param name=&allowFullScreen& value=&false& /&
& & &param name=&movie& value=&../SWFUpload/SWFFileUpload.swf& /&
& & &param name=&quality& value=&high& /&
& & &param name=&bgcolor& value=&#ffffff& /&
& & &param name=&FlashVars& value=&ComJsFun=UploadForEditor&/&
& & &embed src=&../SWFUpload/SWFFileUpload.swf& quality=&high& bgcolor=&#ffffff& width=&400& height=&56& name=&SWFFileUpload& align=&middle& allowScriptAccess=&sameDomain& allowFullScreen=&false& type=&application/x-shockwave-flash& pluginspage=&/go/getflashplayer& /&
& & &/object&
&/noscript&
&div id=&showInfo&&&/div&
&script language=&javascript& type=&text/javascript&&
function UploadForEditor(Value){
alert(Value);
//var RSArr = Value.split(&|&);
//UploaFile(RSArr[0],RSArr[1],RSArr[2],RSArr[3],RSArr[4]);
复制代码源码下载:附件: 亲,您没有权限下载或查看附件喔:-)
试试 或 吧!
下来试用下,哈哈
我K..要不要这么长呀...
我K..要不要这么长呀...
下来看看吧
有兴趣看看
有兴趣看看,但愿有帮助
下来试用下,哈哈
顶~~~~~~~~~
下来试用下,哈哈
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
还能下载麽
0 ? parseInt(this.value) : 1) + '.html';}else{window.location='showtopic.aspx?keywordsurl=&page=' + (parseInt(this.value) > 0 ? parseInt(this.value) : 1);}}if((event.keyCode >= 48 && event.keyCode / 27
Powered by
CopyRight &

我要回帖

更多关于 flex 对话框 的文章

 

随机推荐