SWFSize logo

Docs

Supported Browsers

  • Camino 1+
  • Google Chrome 3+
  • Internet Explorer 6+
  • Mozilla FireFox 2+
  • Opera 9.5+
  • Safari 1.3+

ASDocs [as3]

View the asdocs online

Quick startup

Include the SWFSize javascript file (swfsize.js) right after the SWFObject js, set the attrubutes.id and the flashvars.swfsizeId = attributes.id. After that create a new instance of the SWFSize class and pass the swf's attributes.id to swfsize (an ID for the swf movie is required).

		<script type="text/javascript" src="include/js/swfobject.js"></script>
		<script type="text/javascript" src="include/js/swfsize.js"></script>
		<script type="text/javascript">
		var attributes = {id:'swfID'};
        
		var flashvars = {};
        flashvars.swfsizeId = attributes.id;

		var params = {menu:'false'};
		swfobject.embedSWF('mywebsite.swf', 'mywebsite', "100%", "100%", '9', 'expressInstall.swf', flashvars, params, attributes);
		
        // now all you need to do is create a new SWFSize instance and pass it the swf's id;
        var swfsize = new SWFSize();
        swfsize.setId(attributes.id);
		</script>

Import the SWFSize classes from the 'swfsize' package (SWFSize comes only in AS3).
Now that you've imported the package, initialize the SWFSize class using the singleton instantiation.

		// import the SWFSize api
		import com.chargedweb.swfsize.SWFSize;
		import com.chargedweb.swfsize.SWFSizeEvent;
        
        // initialize SWFSize
        var swfSizer:SWFSize = SWFSize.getInstance();
        

Now that you've initialized the SWFSize you can start coding your apps logic.
Retrieve window coordinates and metrics when SWFSize is initialized, for example.

        swfSizer.addEventListener(SWFSizeEvent.INIT, onSWFSizeInit);

		function onSWFSizeInit(event:SWFSizeEvent):void
		{
        	// your code logic goes here
            // eg: retrieve window coordinates and metrics on init 
        	trace(event.topY, event.bottomY, event.leftX, event.rightX);
            trace(swfSizer.windowWidth, swfSizer.windowHeight);
        }