Flex结合JavaScript读取本地路径的方法_Flex

mxml代码
<!--ReadLocalFile.mxml-->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
     <![CDATA[

       private function init():void
       {
           ExternalInterface.addCallback("OnFileChange",frSelectHandler);//注册JS回调
           btnBrowser.addEventListener(MouseEvent.CLICK,mouseClickHandler);
       }

       private function mouseClickHandler(event:MouseEvent):void
       {
           ExternalInterface.call("Browser");//调用JS中Browser函数
       }

       private function frSelectHandler(path:String):void
       {
           imgTest.source = path;
       }
     ]]>
</mx:Script>
     <mx:Button id="btnBrowser" x="10" y="10" label="Button" />
     <mx:Image id="imgTest"   x="10" y="50"/>
</mx:Application>

html端代码
<!-- ReadLocalFile.html -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="history/history.css" />
<title></title>
<script src="AC_OETags.js" language="javascript"></script>
<script src="history/history.js" language="javascript"></script>
<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 28;
//关键代码
function Browser()
{
document.getElementById("fileInput").click();
}
function OnFileChange()
{
thisMovie("ReadLocalFile").OnFileChange(document.getElementById("fileInput").value);
}
function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }
</script>
</head>
<body scroll="no">
<input type="file" id="fileInput" style="display:none" onchange="OnFileChange()" /><!--fileInput控件-->
<script language="JavaScript" type="text/javascript">
var hasProductInstall = DetectFlashVer(6, 0, 65);
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if ( hasProductInstall && !hasRequestedVersion ) {
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
     document.title = document.title.slice(0, 47) + " - Flash Player Installation";
     var MMdoctitle = document.title;
AC_FL_RunContent(
   "src", "playerProductInstall",
   "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
   "width", "100%",
   "height", "100%",
   "align", "middle",
   "id", "ReadLocalFile",
   "quality", "high",
   "bgcolor", "#869ca7",
   "name", "ReadLocalFile",
   "allowScriptAccess","sameDomain",
   "type", "application/x-shockwave-flash",
   "pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
AC_FL_RunContent(
   "src", "ReadLocalFile",
   "width", "100%",
   "height", "100%",
   "align", "middle",
   "id", "ReadLocalFile",
   "quality", "high",
   "bgcolor", "#869ca7",
   "name", "ReadLocalFile",
   "allowScriptAccess","sameDomain",
   "type", "application/x-shockwave-flash",
   "pluginspage", "http://www.adobe.com/go/getflashplayer"
);
   } else {   // flash is too old or we can't detect the plugin
     var alternateContent = 'Alternate HTML content should be placed here. '
   + 'This content requires the Adobe Flash Player. '
     + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
     document.write(alternateContent);   // insert non-flash content
   }
</script>
<noscript>
   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   id="ReadLocalFile" width="100%" height="100%"
   codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
   <param name="movie" value="ReadLocalFile.swf" />
   <param name="quality" value="high" />
   <param name="bgcolor" value="#869ca7" />
   <param name="allowScriptAccess" value="sameDomain" />
   <embed src="ReadLocalFile.swf" quality="high" bgcolor="#869ca7"
     width="100%" height="100%" name="ReadLocalFile" align="middle"
     play="true"
     loop="false"
     quality="high"
     allowScriptAccess="sameDomain"
     type="application/x-shockwave-flash"
     pluginspage="http://www.adobe.com/go/getflashplayer">
   </embed>
</object>
</noscript>
</body>
</html>

时间: 2024-09-30 04:33:49

Flex结合JavaScript读取本地路径的方法_Flex的相关文章

通过Javascript读取本地Excel文件内容的代码示例

 这篇文章主要介绍了通过Javascript读取本地Excel文件内容的代码示例,但需要一定的条件才可以使用js操作本地文件,需要的朋友参考下吧 读取本地Excel文件内容的Javascript代码:    代码如下: <script type="text/javascript"> function read_excel(){       var filePath="D:abcd9.com.xls"; //要读取的xls     var sheet_id

html-如何利用javascript读取本地Excel的部分数据

问题描述 如何利用javascript读取本地Excel的部分数据 我想做一个场所的查询系统,在主界面的地图上标注出场所来,点击场所可以跳转到这个场所对应的html界面来展示详细信息,这样的话就得有很多个的html来做跳转用,因为每个场所的html除了title,场所的文字描述和两张图片不同,其余的都是相同的. 我想知道能不能在本地创建一个excel表格把所有场所的属性信息都写在表格里,只需要写一个跳转的html,不同的值通过调用表格上对应的值就行了. 不知道该如何实现,求大神指导 解决方案 不

Android以最省内存的方式读取本地资源的方法

方法一: /** * 获取本地图片并指定高度和宽度 */ public static Bitmap getNativeImage(String imagePath) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; // 获取这个图片的宽和高 Bitmap myBitmap = BitmapFactory.decodeFile(imagePath, o

通过Javascript读取本地Excel文件内容的代码示例_javascript技巧

读取本地Excel文件内容的Javascript代码: 复制代码 代码如下: <script type="text/javascript">function read_excel(){     var filePath="D:\abcd9.com.xls"; //要读取的xls    var sheet_id=2; //读取第2个表    var row_start=3; //从第3行开始读取    var tempStr='';    try{    

img无法读取本地路径图片

问题描述 我想做一个图片上传,并且本地预览功能,但是,IE7以后浏览器不支持从本地读取图片的功能,该如何解决本地预览功能,求大神解决 解决方案 解决方案二:浏览器是不能查看本地图片的,兄弟放弃吧,我之前也想这么干.除非你写一个ActiveX控件查看本地文件,而且只能用IE打开解决方案三:都是上传后预览的把解决方案四:真的就没有办法了吗?不会吧,那也太悲催了,我记得有的网站是可以的,大家在帮帮想想,谢谢了解决方案五:就写个activeX呗解决方案六:Referthis:解决方案七:引用5楼insu

Flex 和JavaScript 交互(带参)_Flex

Flex文件: 复制代码 代码如下: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="200" height="150" creationComplete="init

Flex调Javascript打开新窗口示例代码_Flex

测试应用TestJavascript.mxml 复制代码 代码如下: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adob

Android编程实现读取本地SD卡图片的方法_Android

本文实例讲述了Android编程实现读取本地SD卡图片的方法.分享给大家供大家参考,具体如下: private Bitmap getDiskBitmap(String pathString) { Bitmap bitmap = null; try { File file = new File(pathString); if(file.exists()) { bitmap = BitmapFactory.decodeFile(pathString); } } catch (Exception e)

Android编程实现读取本地SD卡图片的方法

本文实例讲述了Android编程实现读取本地SD卡图片的方法.分享给大家供大家参考,具体如下: private Bitmap getDiskBitmap(String pathString) { Bitmap bitmap = null; try { File file = new File(pathString); if(file.exists()) { bitmap = BitmapFactory.decodeFile(pathString); } } catch (Exception e)