Reputation: 10192
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
Upvotes: 0
Views: 7393
Reputation: 52
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 communication test page with callback
and Dynamic Embed method:Browser communication test page with callback
Upvotes: 2
Reputation: 342
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
);
Upvotes: 1
Reputation: 5608
you 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:.....).
Upvotes: 5
Reputation: 9055
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.com/p/swfobject/
This is a beginners tutorial available from Adobe (for SWFObject):
http://www.adobe.com/devnet/flashplayer/articles/swfobject.html
Look for getObjectById()
in the API documentation by following this link:
http://code.google.com/p/swfobject/wiki/api
Upvotes: 0