Edit: I think I finally figured it out! You simply have set the useExternalInterfaces
to Yes
.
So in your code you would change
<param
name="FlashVars"
value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx" />
to
<param
name="FlashVars"
value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes" />
and do the same for the <embed>
tag.
If you visit the demo site and run the following code in Firebug it returns 0
before you select files and the correct count after you select files. Also, if you check the source, you'll see that the useExternalInterface
option is set to Yes
alert(document.getElementById('MultiPowUpload').filesCount());
P.S. You should consider using the SWFObject script included with MultiPowUpload. It lets you set and change variables easily without having to worry about cross-browser issues and it also degrades gracefully for users without flash.
Further edit
To answer your comment: Yes, I've got filesCount
working on my machine.
One thing I forgot to mention is that you might be trying to retrieve filesCount
before the flash control is fully loaded.
The following is the code I'm using. I copied your code exactly and added the useExternalInterface
setting as well as my own javascript.
Note that my javascript code repeatedly checks the filesCount
every 500 milliseconds using the setInterval
function.
<object id="FlashFilesUpload1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" viewastext>
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values!
The same parameters values should be set for EMBED object below. -->
<param name="FlashVars" value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes" />
<param name="BGColor" value="#F8F6E6" />
<param name="Movie" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="Src" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="WMode" value="Window" />
<param name="Play" value="-1" />
<param name="Loop" value="-1" />
<param name="Quality" value="High" />
<param name="SAlign" value="" />
<param name="Menu" value="-1" />
<param name="Base" value="" />
<param name="AllowScriptAccess" value="always" />
<param name="Scale" value="ShowAll" />
<param name="DeviceFont" value="0" />
<param name="EmbedMovie" value="0" />
<param name="SWRemote" value="" />
<param name="MovieData" value="" />
<param name="SeamlessTabbing" value="1" />
<param name="Profile" value="0" />
<param name="ProfileAddress" value="" />
<param name="ProfilePort" value="0" />
<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
<!-- Replace symbols " with the " at all parameters values and symbols "&" with the "%26" at URL values or & at other values! -->
<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ClientSideControls/ElementITMultiPowUpload2.1.swf"
quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="450" height="350" flashvars="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes">
</embed>
</object>
<script>
function updateMessage() {
var message = (new Date()).toLocaleTimeString() + ': ';
try {
var objectElement = document.getElementsByTagName('object')[0];
var embedElement = document.getElementsByTagName('embed')[0];
if (objectElement.filesCount) {
message += 'We are in IE ' + objectElement.filesCount();
}
else if (embedElement.filesCount) {
message += 'We are in Firefox ' + embedElement.filesCount();
}
else {
message += "The flash object is not loaded or useExternalInterface is not set to 'Yes'";
}
}
catch (exp) {
message += 'An error occurred';
}
document.getElementById('message').innerHTML = message;
}
// Update the message every 500 milliseconds
setInterval(updateMessage, 500);
</script>