IMPORTANT: This project isn't being activelly maintained anymore and needs contributors, use it with care and make sure you read these notes and check the issues list.

Each swffit version release consumes an absurd amount of time since I need to do regression tests on many different browsers and on different platforms and there is no reliable way to automate these tests (need to rescale the browser in diffent ways, check positioning, different options, etc...)

Sorry for the incovenience but it's been more than 2yrs since I coded my last Flash website (or used swffit on any project) and I'be been busy coding things that I actually use and specially with client projects.

Why?

swffit was made to improve accessibility of your flash website.

It was made because each user uses a different screen resolution and resizes the browser window at custom sizes.. when you set the flash size to 100% width and/or height (full bleed) the browser won't generate scrollbars and maybe an important content will be hidden for the user.

What it does?

swffit automatically resizes your flash to 100% width and 100% height (full bleed) when your browser window is greater than the minimum desired size and resizes flash to the minimum desired size when the browser window is smaller... It can also resize the flash movie to a maximum size if the browser window size is greater than the maximum size...

How do i use it?

Include the swffit.js Javascript file, then just call one simple javascript function.

startFit():void

Used after calling the "stopFit" method or after changing any public javascript properties.

addResizeEvent():void

Add a javascript function to the onresize event queue.

swffit.addResizeEvent(function);

function:Function - Function that will be fired every time the window is resized.

removeResizeEvent():void

Remove javascript onresize event.

swffit.removeResizeEvent(function);

function:Function - Function that will be removed from the onresize event queue.

getValueOf():*

Return the value of the desired property.

swffit.getValueOf('property');

property:String - Desired property name.

@return:* - Desired property value (String, Number or Boolean).

obs: This method isn't public in the Actionscript Class.

showScrollH():void

Show horizontal scrollbar.

swffit.showScrollH();

IMPORTANT! - Should be called before swfobject.embedSWF or it will reload the flash file.

obs: This method doesn't exist in the Actionscript Class.

showScrollV():void

Show vertical scrollbar.

swffit.showScrollV();

IMPORTANT! - Should be called before swfobject.embedSWF or it will reload the flash file.

obs: This method doesn't exist in the Actionscript Class.

getScrollTop():int

Return the document scroll top property.

swffit.getScrollTop();

@return:int - The number of pixels until the top of the document.

obs: This method is only available for version 2.4+.

getScrollLeft():int

Return the document scroll left property.

swffit.getScrollLeft();

@return:int - The number of pixels until the left of the document.

obs: This method is only available for version 2.4+.

Public Properties (AS Class only):

obs: These properties are only public in the Actionscript Class.

target:String

The ID of the flash movie.

SWFFit.target = t;

t:String - The ID of the flash object/embed tag.

minWid:int

Minimum Width.

SWFFit.minWid = w;

w:int - Minimum desired width (px).

minHei:int

Minimum Height.

SWFFit.minHei = h;

h:int - Minimum desired height (px).

maxWid:int

Maximum Width.

SWFFit.maxWid = w;

w:int - Maximum desired width (px).

maxHei:int

Maximum Height.

SWFFit.maxHei = h;

h:int - Maximum desired height (px).

hCenter:Boolean

Horizontal Centered.

SWFFit.hCenter = c;

c:Boolean - Sets if the flash movie will be centered horizontally after reach maximum size, default value is true.

vCenter:Boolean

Vertical Centered.

SWFFit.vCenter = c;

c:Boolean - Sets if the flash movie will be centered vertically after reach maximum size, default value is true.

Events (AS Class only):

SWFFitEvent.CHANGE

Change event. Dispatched every time a property changes.

SWFFitEvent.CHANGE = "change";

SWFFitEvent.START_FIT

Start Fit event. Dispatched every time the SWFFit.startFit method is called.

SWFFitEvent.START_FIT = "startFit";

SWFFitEvent.STOP_FIT

Stop Fit event. Dispatched every time the SWFFit.stopFit method is called.

SWFFitEvent.STOP_FIT = "stopFit";

obs: All events are only available in the Actionscript Class and are only dispatched when you change the properties or call the methods using the AS class.

Tips:

If you want to set only 'minWid' or 'minHei' set the other as 1..
If you want to set a max size for only one axis ('maxWid' or 'maxHei') set the other one as null.
Always set 'maxWid' to a value greater than 'minWid' or swffit won't work properly..
Copy the example page that comes with the swffit.zip file and just change what you need, this is the easiest way to avoid bugs.
The Actionscript Class have all the methods of the Javascript "Class", the only differences are: the AS class is called 'SWFFit' instead of 'swffit', the 'getValueOf()' method isn't public in the AS class and all the javascript properties aren't public.

Ps2: To learn more about SWFAddress visit the SWFAddress website. I've made the example page only because some people can't make it work together with swffit and SWFObject 2. The only things I've changed from the original SWFAddress example page was the HTML file and also deleted the photos to reduce filesize.

Is it crossbrowser?

I've tested it on mac (safari, firefox, opera, mozilla) and pc (ie, firefox, opera, safari, netscape, chrome) and worked well.. I think it should work in every modern browser that supports javascript..

Download

Download the latest version of swffit. You can use it for whatever you want with no restrictions just keep the credits in the swffit.js file. This software is released under the MIT License

Who made it and Why he did?

swffit was made by Miller Medeiros. I had the idea when i was making my own portfolio in July/2006 and wanted to use the flash with 100% width and 100% height. By that time i didn't found any script that can do what swffit does and i decided to code it by myself..