+1  A: 

Check out this SWFFit Tutorial.

And test to see if changing your width="300" height="300" to width="100%" height="100%" does anything. If you have that and the explicit sizes in swffit.fit("my_flash", 800, 600);, swffit sets the minimum size, so if your browser viewport is below them, the scrollbars appear, if it's above them, the swf resizes too 100% width and height.

Then to dynamically resize your swf from Actionscript, use the com.millermedeiros.swffit.SWFFit class. You can call SWFFit.fit(...) and a few other methods from ActionScript and it will do all the javascript to resize it.

There's a few sample .fla's in the swffit source, take a look at how they do it there.

Update: Here is some code that demonstrates how to resize the swf from within ActionScript.

Sample App

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute">

    <mx:Script>
        import com.millermedeiros.swffit.*;

        public static const FLASH_ID:String = "my_flash";

        public function updateSize():void
        {
            var width:Number = widthSlider.value;
            var height:Number = heightSlider.value;
            trace("width: ", width, " height: ", height);
            SWFFit.fit(FLASH_ID, width, height);
        }
    </mx:Script>

    <mx:Panel backgroundColor="0xaaaaaa" width="80%" height="80%"
        horizontalCenter="0" verticalCenter="0"/>

    <mx:VBox width="100%" height="100%">
        <mx:Label text="Width"/>
        <mx:HSlider id="widthSlider" liveDragging="true" change="updateSize()"
            minimum="300" maximum="2000"/>
        <mx:Label text="Height"/>
        <mx:HSlider id="heightSlider" liveDragging="true" change="updateSize()"
            minimum="300" maximum="2000"/>
    </mx:VBox>
</mx:Application>             

Sample HTML Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript" src="swffit.js"></script>
        <script type="text/javascript">
            swfobject.registerObject("my_flash", "10.0.0", "expressInstall.swf");
            swffit.fit("my_flash", 800, 600);
        </script>
    </head>

    <body>
        <object id="my_flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%">
            <param name="movie" value="Sample.swf" />
            <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="Sample.swf" width="100%" height="100%">
        <!--<![endif]-->

        <div>
            <a href="http://www.adobe.com/go/getflashplayer"&gt;&lt;img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" title="Get Adobe Flash player" /></a><br />
            You need <a href="http://www.adobe.com/go/getflashplayer"&gt;Flash Player 10</a> and allow javascript to see the content of this site..
        </div>
        <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
        </object>

    </body>
</html>

Best, Lance

viatropos
I am using flex builder (and flex), and a little but confused about how to look at those flas code?So will be more then happy to get short example in actionscript...
Oleg Tarasenko
try the sample code now :)
viatropos