admin管理员组文章数量:1355825
This is my AC3 code
private function uploadet( dosya:String ):void {
var uploader:URLRequest = new URLRequest(dosya);
localFile.upload(uploader);
}
var a = flash.external.ExternalInterface.addCallback("uploadet",uploadet);
And this is Javascript
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "9.0.0", "expressInstall.swf");
function uploadet(dosya){
var myFlashMovie = swfobject.getObjectById("myId");
myFlashMovie.uploadet(dosya);
}
</script>
<style type="text/css">
<!--
body {
background-color: #e6e6e6;
margin-top: 50px;
}
-->
</style></head>
<body >
<object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
<param name="movie" value="SimpleUploader.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="SimpleUploader.swf" width="300" height="120">
<!--<![endif]-->
<div>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
<div id="flash" align="center">
</div>
<div align="center"><b>Javascript Feedback:</b></div>
<div align="center" id="output"></div>
<input type="button" name="Submit" value="Submit" onclick="uploadet('dsadsa.php');" />
I cant get it work, any help is appreciated.
Thanks
This is my AC3 code
private function uploadet( dosya:String ):void {
var uploader:URLRequest = new URLRequest(dosya);
localFile.upload(uploader);
}
var a = flash.external.ExternalInterface.addCallback("uploadet",uploadet);
And this is Javascript
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "9.0.0", "expressInstall.swf");
function uploadet(dosya){
var myFlashMovie = swfobject.getObjectById("myId");
myFlashMovie.uploadet(dosya);
}
</script>
<style type="text/css">
<!--
body {
background-color: #e6e6e6;
margin-top: 50px;
}
-->
</style></head>
<body >
<object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
<param name="movie" value="SimpleUploader.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="SimpleUploader.swf" width="300" height="120">
<!--<![endif]-->
<div>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
<div id="flash" align="center">
</div>
<div align="center"><b>Javascript Feedback:</b></div>
<div align="center" id="output"></div>
<input type="button" name="Submit" value="Submit" onclick="uploadet('dsadsa.php');" />
I cant get it work, any help is appreciated.
Thanks
Share Improve this question edited Nov 4, 2009 at 19:20 Utku Dalmaz asked Nov 4, 2009 at 18:35 Utku DalmazUtku Dalmaz 10.2k30 gold badges92 silver badges133 bronze badges4 Answers
Reset to default 5you must deploy the flash app on a webserver in order to test it (or make yourself a local web server). flash player won't allow you to use external interface if you load the file from local host as a file (file:///c:.....).
Do not use getObjectById method to get the swf object. You can use the following code:
swfobject.registerObject("myId", "9.0.0", "expressInstall.swf", callbackFn);
function callbackFn(status) {
if (status.success) {
var obj = status.ref;
document.getElementById("but1").onclick = function() {
if (obj && typeof obj.uploadet!= "undefined") {
obj.uploadet(dosya);
}
};
}
More details you can refer to Static Embed method:Browser munication test page with callback
and Dynamic Embed method:Browser munication test page with callback
You cannot use the ExternalInterface without allowing scripting when you embed the SWF, read this Adobe Knowledge Base document for more information. In other words, use this HTML if you're embedding it directly on the page:
<object ... >
.
.
.
<param name="allowScriptAccess" value="always"/>
</object>
Or the following if you're using SWFObject:
var parametersObj = { allowScriptAccess: "always" };
swfobject.embedSWF(
swfPath,
targetElement,
swfWidth,
swfHeight,
minFlashVersion,
expressInstall,
flashvarsObj,
parametersObj,
attributesObj
);
Your problem is that you are probably not reaching the right <OBJECT>
element using:
var myFlashMovie = document.getElementById('simpleUploader');
Your nested tags have the same id attribute, producing unexpected results.
You should use SWFObject (a widely known and used flash embedding library) to embed your flash movie and use the method swfobject.getObjectById()
to properly access your <OBJECT>
tags.
To learn more about SWFObject, follow this link:
http://code.google./p/swfobject/
This is a beginners tutorial available from Adobe (for SWFObject):
http://www.adobe./devnet/flashplayer/articles/swfobject.html
Look for getObjectById()
in the API documentation by following this link:
http://code.google./p/swfobject/wiki/api
本文标签: javascriptExternalInterfaceaddCallback is not workingStack Overflow
版权声明:本文标题:javascript - ExternalInterface.addCallback is not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744009033a2575224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论