4 Replies Latest reply on Sep 29, 2009 11:10 PM by AttaBoy2

    resizeable .swf?

    steve-lucky

      i have an .swf that's fairly large (dimensions, not file size) and i'd like to make it so that when i put it in a web page it will resize itself based on the size of the browser window. so if they shrink down their browser it will still be in the same spot and completely visable. is there a way to do this?

        • 1. Re: resizeable .swf?
          AttaBoy2 Level 4

          AS2 version:

          import flash.display.BitmapData;

           

          shelter._x = Stage.width / 2;
          shelter._y = Stage.height / 2;

           

          var tile:BitmapData = BitmapData.loadBitmap("tile");

           

          function fillBG()
          {
              this.beginBitmapFill(tile);
              this.moveTo(0,0);
              this.lineTo(Stage.width,0);
              this.lineTo(Stage.width,Stage.height);
              this.lineTo(0,Stage.height);
              this.lineTo(0,0);
              this.endFill();
          }

           

          fillBG();

           

          var stageL:Object = new Object();
          stageL.onResize = function()
          {
              fillBG();
              shelter._x = Stage.width / 2;
              shelter._y = Stage.height / 2;
          }

           

          Stage.addListener(stageL);

           

           

           

           

          AS3 version:

           

          stage.align = StageAlign.TOP_LEFT;
          stage.scaleMode = StageScaleMode.NO_SCALE;

          var bmp:Tile = new Tile(35, 35);
          var tile:BitmapData = new BitmapData(35, 35);
          tile.draw(bmp);

           

          shelter.x = stage.stageWidth /2;
          shelter.y = stage.stageHeight /2;

          function fillBG(evt:Event = null):void {
            graphics.beginBitmapFill(tile);
            graphics.moveTo(0, 0);
            graphics.lineTo(stage.stageWidth, 0);
            graphics.lineTo(stage.stageWidth, stage.stageHeight);
            graphics.lineTo(0, stage.stageHeight);
            graphics.lineTo(0, 0);
            graphics.endFill();
          shelter.x = stage.stageWidth /2;
          shelter.y = stage.stageHeight /2;
          };
          fillBG();

          stage.addEventListener(Event.RESIZE, fillBG);

           

           

          In both versions you need to set dimension to percent in the html tab of your publish settings

          and add this css rule to your html

          body {margin:0; padding:0; overflow: auto}

          • 2. Re: resizeable .swf?
            steve-lucky Level 1

            so, where does that code go? in my html? i'm currently using dreamweaver to place the .swf. I just click insert, media and place the .swf like that so it generates tha code. now i'm no stranger to code so i can place it, i'm just not sure where.

             

            but the more that i look at it, it looks like that's just actionscript so it goes right in my swf then?

            • 3. Re: resizeable .swf?
              steve-lucky Level 1

              so, where does that code go? in my html? i'm currently using dreamweaver to place the .swf. I just click insert, media and place the .swf like that so it generates tha code. now i'm no stranger to code so i can place it, i'm just not sure where.

               

              but the more that i look at it, it looks like that's just actionscript so it goes right in my swf then?

              • 4. Re: resizeable .swf?
                AttaBoy2 Level 4

                The only code that goes in your html is the css rule for your body tag.  Since you have a working version in the zip file I attached all you need do is open the fla,  coustomize it to sute your needs and publish.  It will generate it's own html.