js与flash交互操作1

简介: //flash里传送值 '' //flash里获取值 this.uploadURL=root.loaderinfo.parameters.



//flash里传送值
'<param name="flashvars" value="' + this.getFlashVars() + '" />'
//flash里获取值
this.uploadURL=root.loaderinfo.parameters.uploadURL

SWFUpload.prototype.getFlashVars = function () {
   // Build a string from the post param object
   var paramString = this.buildParamString();
   var httpSuccessString = this.settings.http_success.join(",");
   
   // Build the parameter string
   return ["movieName=", encodeURIComponent(this.movieName),
           "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
           "&amp;useQueryString=", encodeURIComponent

(this.settings.use_query_string),
           "&amp;requeueOnError=", encodeURIComponent

(this.settings.requeue_on_error),
           "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
           "&amp;assumeSuccessTimeout=", encodeURIComponent

(this.settings.assume_success_timeout),
           "&amp;params=", encodeURIComponent(paramString),
           "&amp;filePostName=", encodeURIComponent

(this.settings.file_post_name),
           "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
           "&amp;fileTypesDescription=", encodeURIComponent

(this.settings.file_types_description),
           "&amp;fileSizeLimit=", encodeURIComponent

(this.settings.file_size_limit),
           "&amp;fileUploadLimit=", encodeURIComponent

(this.settings.file_upload_limit),
           "&amp;fileQueueLimit=", encodeURIComponent

(this.settings.file_queue_limit),
           "&amp;debugEnabled=", encodeURIComponent

(this.settings.debug_enabled),
           "&amp;buttonImageURL=", encodeURIComponent

(this.settings.button_image_url),
           "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
           "&amp;buttonHeight=", encodeURIComponent

(this.settings.button_height),
           "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
           "&amp;buttonTextTopPadding=", encodeURIComponent

(this.settings.button_text_top_padding),
           "&amp;buttonTextLeftPadding=", encodeURIComponent

(this.settings.button_text_left_padding),
           "&amp;buttonTextStyle=", encodeURIComponent

(this.settings.button_text_style),
           "&amp;buttonAction=", encodeURIComponent

(this.settings.button_action),
           "&amp;buttonDisabled=", encodeURIComponent

(this.settings.button_disabled),
           "&amp;buttonCursor=", encodeURIComponent

(this.settings.button_cursor)
       ].join("");
};
//js调用flash中的方法
SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
   argumentArray = argumentArray || [];
   
   var movieElement = this.getMovieElement();
   var returnValue, returnString;

   // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
   try {
       returnString = movieElement.CallFunction('<invoke name="' + functionName +

'" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
       returnValue = eval(returnString);
   } catch (ex) {
       throw "Call to " + functionName + " failed";
   }
   
   // Unescape file post param values
   if (returnValue != undefined && typeof returnValue.post === "object") {
       returnValue = this.unescapeFilePostParams(returnValue);
   }

   return returnValue;
};
//调用
SWFUpload.prototype.getStats = function () {
   return this.callFlash("GetStats");
};
SWFUpload.prototype.getFile = function (fileID) {
   if (typeof(fileID) === "number") {
       return this.callFlash("GetFileByIndex", [fileID]);
   } else {
       return this.callFlash("GetFile", [fileID]);
   }
};
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
   return this.callFlash("AddFileParam", [fileID, name, value]);
};

SWFUpload.prototype.getMovieElement = function () {
   if (this.movieElement == undefined) {//this.movieName就是flash object的id
       this.movieElement = document.getElementById(this.movieName);
   }

   if (this.movieElement === null) {
       throw "Could not find Flash element";
   }
   
   return this.movieElement;
};
相关文章
|
11天前
|
缓存 JavaScript 前端开发
【JavaScript 技术专栏】DOM 操作全攻略:从基础到进阶
【4月更文挑战第30天】本文深入讲解JavaScript与DOM交互,涵盖DOM基础、获取/修改元素、创建/删除元素、事件处理结合及性能优化。通过学习,开发者能掌握动态改变网页内容、结构和样式的技能,实现更丰富的交互体验。文中还讨论了DOM操作在实际案例、与其他前端技术结合的应用,助你提升前端开发能力。
|
5天前
|
JavaScript 前端开发
javascript操作BOM的方法
javascript操作BOM的方法
13 0
|
23小时前
|
JavaScript 前端开发
JavaScript 提供了多种方法来操作 DOM(文档对象模型)
【5月更文挑战第11天】JavaScript 用于DOM操作的方法包括获取元素(getElementById, getElementsByClassName等)、修改内容(innerHTML, innerText, textContent)、改变属性、添加/删除元素(appendChild, removeChild)和调整样式。此外,addEventListener用于监听事件。注意要考虑兼容性和性能当使用这些技术。
6 2
|
2天前
|
JavaScript 前端开发 UED
在 JavaScript 中,异步编程和回调函数是处理非阻塞操作(如网络请求、文件读写等)的重要工具
【5月更文挑战第10天】JavaScript中的异步编程和回调函数用于处理非阻塞操作,提高应用响应性和吞吐量。异步编程通过回调函数、Promises和async/await等方式实现,避免程序因等待操作完成而阻塞。回调函数是异步操作完成后调用的函数,常用于处理网络请求等。然而,回调函数存在嵌套问题和错误处理困难,因此出现了Promises和async/await等更优解决方案。
10 3
|
2天前
|
Web App开发 JavaScript 前端开发
javascript操作DIV总结 转
javascript操作DIV总结 转
|
5天前
|
JavaScript 前端开发 安全
javascript操作DOM的方法
javascript操作DOM的方法
11 0
|
5天前
|
JavaScript 前端开发 容器
js操作dom元素
js操作dom元素
13 0
|
5天前
|
JavaScript 前端开发
js的交互事件
js的交互事件
12 1
|
5天前
|
JavaScript 前端开发 索引
js操作字符串的方法
js操作字符串的方法
14 2
|
12天前
|
存储 缓存 JavaScript
【Web 前端】JS哪些操作会造成内存泄露?
【4月更文挑战第22天】【Web 前端】JS哪些操作会造成内存泄露?