开发者

Dynamically load SWF file with Java

I want to load SWF file dynamically in my webpage. But I don't know how to do it. Is it possible to load SWF from back-end? In this website Insert SWF into html page I found a way to load SWF, but it is static. I have a database where I will store the paths of the SWF files and load those files dynamically. Is there any way to dynamical开发者_JAVA技巧ly change the source of the swf object [ "EMBED SRC="file.swf" ]? Any information will be very helpful to me. Thank you.


Though I have no personal experience using Wicket, but here's how I understood it should go. Use the AttributeModifier to change the value of the value attribute of the param tag and the src attribute of the movie tag. You also need to give them the Wicket id's on the HTML template to be able to refer them from the Java code. In general the HTML template would look something like this:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  width="300" height="170"
  codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
  <param wicket:id="swfReference1" name="movie" value="" />
  <param name="quality" value="high" />
  <param name="bgcolor" value="#000000" />
  <param name="allowScriptAccess" value="always" />
  <embed wicket:id="swfReference2" src="" quality="high" bgcolor="#000000"
    width="300" height="170" align="middle"
    play="true"
    loop="false"
    allowScriptAccess="always"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer">
  </embed>
</object>
...

You could also do it on JavaScript level to be even more dynamic by using for instance jQuery to switch the SWF sources. Here's a working example.

$('param[name=movie]').attr('value', 'https://demo.adobe.com/Home.swf');
$('embed').attr('src', 'https://demo.adobe.com/Home.swf');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜