Developers
How to display a Flash app within a widget?
Flash apps have the same constraints as regular images: while displaying them is self-evident (just add the code), you have to cater for the files which width is bigger than that of the widget. See ”How to display an image within a widget?”
The proper way to handle this for Flash apps is much like the one for images, and media in general: use the widget.getDimensions method.
Here is an example from the simple Fireplace widget:
var Fireplace = {}; widget.onLoad = function() { var contentHtml = ''; contentHtml += '<div style="margin: 0 auto;text-align:center;">'; contentHtml += '<object type="application/x-shockwave-flash" data="http://nvmodules.typhon.net/maurice/fireplace/fire.swf" width="320" height="240" class="flash">'; contentHtml += '<param name="movie" value="http://nvmodules.typhon.net/maurice/fireplace/fire.swf" />'; //contentHtml += '<param name="wmode" value="opaque" />'; contentHtml += '<embed type="application/x-shockwave-flash" src="http://nvmodules.typhon.net/maurice/fireplace/fire.swf" width="320" height="240"></embed>'; contentHtml += '</object>'; contentHtml += '</div>'; widget.setBody(contentHtml); widget.onResize(); } widget.onResize = function() { var elements = widget.body.getElementsByTagName("object"); var flash = elements[0]; if (flash) { flash.width = 1; flash.width = widget.body.getDimensions().width - 10; flash.height = Math.round(flash.width * 3/4); } }
Here again, this has the added value to adapt the size of the image to that of the widget.
- Send to a friend
- Add to favorites
- Last modified: 2008/04/24 23:27

