Flash: Full window flash, and when minimum size scrollbars with SwfObject 2.0’s Dynamic Publishing

by troy on July 31, 2008

In the post "Elastic flash with scrollbars" a nice javascript library is presented to scale full window flash when the browser hits a certain. point. Worked great with SWFObject 1.0, but didn't work with SWFObject 2.0 and dynamic publishing without a tweak.

Here's the Javascript I'm using:

                        var params = {};
			params.allowscriptaccess  = "always";
			params.menu = false;
			var attributes = {};
			attributes.id = "flashUI"; // what to call with External Interface
			attributes.name = "flashUI";
			swfobject.embedSWF("index.swf", "contentToReplaceDiv", "100%", "100%", "9.0.0", "expressInstall.swf", fv, params, attributes);
 
			var scale = new FlashScaler("flashUI", 1280,768);
			scale.resize();

This got the scaling to work but not on the original load, if the window was smaller than the minimum dimensions, as the load event has already been called. So I had to modify FlashScaler to call the resize function during constructor e.g.

function FlashScaler(flashdiv,w,h){
 
	var flashObj = document.getElementById(flashdiv);
	var minW = w;
	var minH = h;
	addWindowEvent("onload",resize);
	addWindowEvent("onresize",resize);
	resize(); //<-- added this line
       .........

SWFForceSize is similar. "Size limiting for full window flash" Not exactly sure how they differ internally, but the approach that might work is hinted in the documentation and API But only when static publishing via the use of

swfobject.getObjectById(objectIdStr)

and perhaps passing it into SWForceSize? Don't know.

UPDATE: FlashScaler with this approach doesn't work with IE6, or IE7, gives script errors, looking into it.

{ 3 comments… read them below or add one }

Jonathan Nicol June 8, 2009 at 8:24 pm

Troy, I’m curious under what conditions FlashScaler doesn’t work during initial page load? The resize() function is called as an onLoad event, and in my tests this works fine. The reason you’ll get JS errors if you call resize() in the constructor is most likely because the DOM hasn’t finished rendering yet, and FlashScaler is trying to resize elements that don’t yet exist.

troy June 10, 2009 at 2:21 pm

Hi Jonathan,

It’s been awhile, the resize worked on FireFox, but not in IE6 an IE7 in previous testing, i didn’t setup the script in any special way, just what was provided with the documentation. *scratches* head.

Jonathan Nicol June 11, 2009 at 9:25 pm

Troy, if you run my demo (http://www.f6design.com/journal/flashscaler/index_dynamic.html) in IE7 with the browser window smaller than the minumum dimensions, does it work?

Leave a Comment

Previous post:

Next post: