Return to Snippet

Revision: 26275
at April 22, 2010 07:58 by cessnajumpin


Initial Code
So this requires both flash and javascript code to get it working correctly.

The flash:

   import flash.external.ExternalInterface;
   public class Main extends Sprite
   {
      public function Main()
      {
         resizeSwf(1000);
      }
      private function resizeSwf(newSize):void
      {
	if (ExternalInterface.available) 
	{
		ExternalInterface.call("resizeEmbed", newSize);
	}
      }
   }

The JavaScript:
   <script language="javascript">
   function resizeEmbed(value) 
   {
	var theSwf = getFlashMovie("Main");
	theSwf.style.height = value;
   }

   function getFlashMovie(movieName)
   {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
   }  
</script>

So you could call the resizeSwf function anywhere you want, just pass in the height that you want the swf to resize to and the javascript will take care of the rest, automatically adding the scrollbars in your browser.

Initial URL

                                

Initial Description
Ever have to make a swf that needs to change height? Want to use the browser's scrollbar instead of having to create one in flash?

Initial Title
Flash Resize the Swf

Initial Tags
javascript, resize, actionscript, flash

Initial Language
ActionScript 3