/ Published in: ActionScript 3
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?
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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.