问题
Bit of a long explanation below, with a hopefully accurate short question summary here:
Can a .NET WebBrowser control (Win7 64-bit, IE9, current Flash 10.3.183.7) load a SWF file into an <object> tag, where the SWF file is in a separate folder that also contains an XML data file in such a way as to have the SWF file load and display the XML data?
UPDATE: Added some more information below based on some further experimentation...
Gory detail:
This has plagued me for a couple of days. Consider the following:
C:\dev\wb.exe
-- program that uses a WebBrowser to show a local SWF file from the disk
c:\data\mySWF.swf
-- the SWF file I want to play
c:\data\myData.xml
-- the file with data that mySWF.swf is looking for
C:\html\index.html
-- HTML file loaded by wb.exe. This file has an <object> tag to set up a Flash ActiveX control playing c:\data\mySWF.swf.
Originally, this started with swfobject.js
being used, and when I didn't see the results I was expecting, I kept simplifying until I got to the point where I don't have anything but an HTML file with no additional libraries.
If I load the index.html
into IE9, it works. I see the SWF file playing with the data from the XML file loaded.
When I run wb.exe, it loads the C:\html\index.html
file, and I see the SWF playing. But the data fields are empty. If I copy the index.html to C:\data\index.html
and load it into wb.exe, THEN I see my data.
My index.html file:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
* {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0">
<object type="application/x-shockwave-flash" width=100%" height="100%" id='player1' name='player1'>
<param name='movie' value='C:\data\mySWF.swf'>
<param name='allowfullscreen' value='true'>
<param name='allowscriptaccess' value='always'>
<param name='base' value='C:\data\'>
<param name='menu' value='false'>
<param name='quality' value='best'>
<param name='scale' value='exactfit'>
</object>
</body>
</html>
The base
parameter seemed to be part of getting this to work, but I'm stymied as to why (or whether) I can get the Flash ActiveX control to work the way I need it to, without having to load an HTML file from the same folder as the SWF file.
UPDATE: If I put the myData.xml file into the C:\html folder, and I load from C:\html\index.html, I get the data values in the SWF. So it seems that the Flash plug-in is using the path of the index.html file, and NOT the base parameter.
UPDATE: We've found out, through more experiementation, that this problem does NOT appear to occur if the SWF file uses Action Script 2 (AS2) for its XML handling (via XML.load()), but a SWF file using Action Script 3 (AS3) (via URLLoader.load()) does NOT work properly. This just gets weirder.
I appreciate your patience if you stuck around this far, and hopefully you might be able to educate me as to my problem.
Thanks.
回答1:
As a follow-up to my own question, there's no nice solution.
We worked around the issue by using jQuery to adjust a <base href="">
tag in the main HTML to refer to the folder with the SWF and XML file in, each time we loaded a new SWF file. That works, but no one's really happy with it.
We talked to Microsoft, and then to Adobe. Adobe calls the use of Flash in a .NET WebBrowser control an "unsupported use case" and doesn't want anything more to do with the issue.
来源:https://stackoverflow.com/questions/7520433/flash-swf-file-cannot-find-xml-data-file-when-loaded-into-webbrowser-control-bu