Rectangle 27 0

If you are doing fullscreen, you need to set your stageScaleMode to NO_SCALE, and embed your flash object into a div that has its height and width parameters set to 100%. To deal with resizing, your flash project needs a resize event listener (applied to the stage), and all display objects need to respond to that resize listener. Once your swf is resizing properly, you can, as already noted, use stage.stageHeight / stageWidth to retrieve exact dimensions internally.

If, on the other hand, you just want to obtain the dimesions of the window, you will need to use ExternalInterface to make a javascript call. jQuery has some nice tools for quickly obtaining screen dimentions. Then its just a matter of sending that data back into flash. Remember that javascript has a resize event, as well, and that you can use it to force state changes in flash.

You're correct in the initial piece of the sequence - sending flashvars in on load, but to respond to screen size changes, you will need to apply one of these techniques.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

flash - AS3: get browser window size? - Stack Overflow

flash actionscript-3 browser window
Rectangle 27 0

Your definitely going to need to call a JS function, the good news is it's really simple code, something like this:

function resizeIt(height)
{
      document.getElementById("myDiv").height = height;
}

Using SWFObject in this case you can set the width and height to be 100%, so it'll resize with the containing DIV, so you're not modifying the embed paramerters, but just the css.

flash - How do you make a SWF resize inside a HTML page? - Stack Overf...

html flash actionscript-3 flash-player
Rectangle 27 0

import flash.display.StageAlign;
import flash.display.StageScaleMode;

...

public function InitializeChatProgram() 
{
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
}

actionscript 3 - flash components and resizing - Stack Overflow

actionscript-3 flash components swf resize
Rectangle 27 0

If you link directly to the swf file (not embedding it in any page) it'll be full-screen.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

flash - How to resize a .swf file depending on screen size? - Stack Ov...

flash dreamweaver
Rectangle 27 0

There isn't a way to specifically set the Loader to size your loaded swf upon completion of a load.

If you always want your loaded swf to be 100% of the stage's width and height, you WOULD need to do a stage resize listener and resize it inside the event handler. If you want it to initialize at 100%, you could do the following inside the loaded swf:

import flash.events.Event

addEventListener (Event.ADDED_TO_STAGE, onAddedToStage);

function onAddedToStage (e:Event):void{
    removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage)
    this.width = stage.stageWidth;
    this.height = stage.stageHeight;
}

flash - auto resize of Loader and loaded SWF - Stack Overflow

flash actionscript-3
Rectangle 27 0

Your Application is sort of like a Canvas inside of the flash player. Thus, you can give it a fixed size (with the width and height attributes), but that will just reduce its size inside the flash player. I don't think you can mess with this in pure AS3 - you'd need to change the underlying HTML (although, you may be able to do this with ExternalInterface, which allows you to call javascript methods on the HTML page...).

flex - How to create fixed size swf in pure AS3 only - Stack Overflow

flex flash actionscript-3 swf resize
Rectangle 27 0

To achieve best quality you should use stage.fullScreenHeight and stage.fullScreenWidth to determine window size and also handle window resizing event. Image and the picture of the building should be a separate movie clip. There is some AS3 code to do that (should be put at the first frame of movie):

import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Sound;
import fl.transitions.Tween;
import fl.transitions.easing.*;


var t:Tween;
var u:Tween;
var i:Tween;



if(stage) init(null);
else addEventListener(Event.ADDED_TO_STAGE, init);

function init(e:Event){

    stage.scaleMode = StageScaleMode.NO_SCALE; //You don't want to scale anything
    stage.align = StageAlign.TOP_LEFT;
    resizeHandler(null);
    stage.addEventListener(Event.RESIZE, resizeHandler); //function that will be executed at every window size change.


  /* some animations.
      new Tween(object, "property", EasingType, begin, end, duration, useSeconds);
      property - This is the name of the property which will be animated, it   must be specified as a string (between quotation marks). Example: "alpha", "scaleX",   "scaleY", "x", "y". so you can calculate this vaules depending on the current window size
   */

    logo_mc.logo1_mc.visible = false;
    logo_mc.logo2_mc.visible = true;
    t=new Tween(bg_top_mc, "height", Strong.easeOut, bg_top_mc.height, 341, 2, true);
    u=new Tween(diamonds_mc, "y", Strong.easeOut, diamonds_mc.y, 208, 2, true);
    i=new Tween(gradients_mc, "y", Strong.easeOut, gradients_mc.y, 221, 2, true);


}

function resizeHandler(e:Event):void {

    var sw = stage.stageWidth;
    var sh = stage.stageHeight;

    //put a footer at the bottom of window 
    footer_bg_mc.width = sw;
    footer_bg_mc.y = sh - footer_bg_mc.height;

    //specify ALL elements positions depending on the window size, it is called liquid layout
    copyright_mc.y = stage.stageHeight - copyright_mc.height - 8;

   //center     
   logo_mc.x = stage.stageWidth - logo_mc.width - 40;

   //you can also scale text size
    var format:TextFormat = new TextFormat();
    format.size = Math.round(stage.stageWidth/20); 
    myTextField.setTextFormat(format);

    gradients_mc.width = stage.stageWidth;
    bg_top_mc.width = stage.stageWidth;
    bg_site_mc.width = sw;
    bg_site_mc.height = sh;

    content_mc.x = 0;
    content_mc.y = 0;
    }
...
<head>
<style type="text/css" media="screen">
        html, body { height:100%; background-color: #27262e;}
        body { margin:0; padding:0; overflow:hidden; }
        #flashContent { width:100%; height:100%; }
        </style>  
...
<body>
<div id="flashContent">
<div id="flashContent">
            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%" id="index" align="middle">
            <param name="allowFullScreen" value="true" />
                <param name="movie" value="index.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#e7e7e7" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="sameDomain" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="index.swf" width="100%" height="100%">
                <param name="allowFullScreen" value="true" />
                    <param name="movie" value="index.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#e7e7e7" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="window" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="" />
                    <param name="allowScriptAccess" value="sameDomain" />
                <!--<![endif]-->
                    <a href="http://www.adobe.com/go/getflash">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                    </a>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object> ...

This liquid layout is not probably the greatest solution for you, but you can use this to make text fit to the window. You can try to "make this building float" both sides can be filled with background. This is not true that if you make everything big that would make downscaled image better looking, that depends on a algorithm.

You can achieve better effect sticking to CSS and JavaScript. the doors can stay in SWF.

Can you explain the AS3 a little? Especially the colors and where the movie clips play into the stage.

I am going to try the CSS approach. If I go that way, I wont need to do any resizing in AS3. I still kind of feel like the problem hasn't been answered completely, though. Do you have any links for AS3 resizing techniques? I am apparently not googling efficiently today.

republicofcode.com/tutorials/flash/as3fluidresize. It doesn't apply to your problem, if you are using flash as "image viewer". There is no way to scale bitmap in Flash very well. You can prepare other versions of SWF or images loaded in to SWF dynamically depending on the window resolutions (republicofcode.com/tutorials/flash/load_images_bc).

html - Resizing SWFs with JavaScript - Stack Overflow

javascript html flash resize swf
Rectangle 27 0

Do you need to alter its dimensions or its length? If it's the dimensions you want to change then it could be as easy as changing the width and height parameters of your embed code, or loading the swf into another one and displaying it behind a mask that shows only the parts you want to show. No change necessary inside the actual swf.

But maybe you meant something else? The width and height of an swf are coded inside it and could be changed with some editor, like a hex editor. But then you would have to know where the bytes are that you need to change.

flash - Is there a way to crop an swf file? - Stack Overflow

flash resize swf flash-player crop
Rectangle 27 0

This function resizes all you objects keeping they aspect ration and using symbols 0.0 point as pivot. Sometimes it means that you have negative scale which mean mirror flips on one or two axises. The better choice for you will be place all your content (animation and stuff) inside new MovieClip and resize it by tranform tool.

Thanks Aspiro! That worked like a charm! I created a MovieClip based on the background I had and then selected every frame in the animation, Copy frames, entered into the MC and Paste frames. Once I did that, I deleted the original animation frames and voil! Thanks again!

You are welcome

actionscript 2 - Resizing SWF document size in Flash, flips all the an...

flash actionscript-2
Rectangle 27 0

Stage's resize event triggers every time the swf changes size, so you don't need to use ExternalInterface (it's less reliable and adds complexity). Also, you should set stage.scaleMode to "noScale" and stage.align to "TL" so the elements won't scale (you will do that manually) and they will be aligned to the top left corner (to maintain consistency with the display list).

Then, on each resize event you can check the new dimensions (stage.stageWidth and stage.stageHeight) and resize/relocate your elements individually (e.g. chatBox.height = stage.stageHeight)

actionscript 3 - Flash AS3: Resize SWF but keep elements the same size...

flash actionscript-3
Rectangle 27 0

If you are doing fullscreen, you need to set your stageScaleMode to NO_SCALE, and embed your flash object into a div that has its height and width parameters set to 100%. To deal with resizing, your flash project needs a resize event listener (applied to the stage), and all display objects need to respond to that resize listener. Once your swf is resizing properly, you can, as already noted, use stage.stageHeight / stageWidth to retrieve exact dimensions internally.

If, on the other hand, you just want to obtain the dimesions of the window, you will need to use ExternalInterface to make a javascript call. jQuery has some nice tools for quickly obtaining screen dimentions. Then its just a matter of sending that data back into flash. Remember that javascript has a resize event, as well, and that you can use it to force state changes in flash.

You're correct in the initial piece of the sequence - sending flashvars in on load, but to respond to screen size changes, you will need to apply one of these techniques.

flash - AS3: get browser window size? - Stack Overflow

flash actionscript-3 browser window
Rectangle 27 0

My opinion is that if the browser has the Flash plugin it will render it, and it's up to you to implement how the swf behaves when you scale/resize the browser window/etc.

You can embed a swf in an HTML page and have it full browser screen offcourse, and you could interact with the browser a bit better ( some nice javascript/flash action going on ), not mention it would be more SEO/standards friendly.

flash - What's browser support like for bare SWF files? - Stack Overfl...

flash actionscript browser flash-player
Rectangle 27 0

In order to resize your objects properly, you need to rearrange them when the size of the window changes. For instance, if your chat component must be horizontally centered, your code would like :

stage.addEventListener(Event.RESIZE, resizeHandler);

private function resizeHandler(event:Event):void {
   component.x = (stage.stageWidth+component.width) / 2;
}

If don't want to rearrange them and scale them proportionally, try to set the stage scale mode to other StageScaleMode values.

actionscript 3 - flash components and resizing - Stack Overflow

actionscript-3 flash components swf resize
Rectangle 27 0

This is not an "answer" but, just to share what I think: I believe this (resizing) depends on the underlying flash (swf) file being able to handle scaling or not. In this particular case, it seems that "Logging-into-cPanel.swf" does not handle it, and does not pay attention to the size of the canvas it resides, and always centers itself (i.e. cropping when the container is smaller)

I haven't done network sniffing, or flash decompiling to see if this SWF file is just a wrapper around a FLV file or something. If that's the case, you may be able to switch to a different player, and handle it, but otherwise, there may not be a way (but then again, I'm not a Flash expert).

html - embed and resize a swf video - Stack Overflow

html swf embed
Rectangle 27 0

You have not dictated a minimum size for the window (or say, body element or a div element) so the browser does not know it needs to produce scrollbars at any particular resize point. Since the browser continues to shrink your SWF, the SWF repositions its elements at the smaller and smaller sizes until they overlap. This isn't strictly a flash problem, but a CSS problem.

Edit: You've also told the SWF Object to not scale the content, which when combined with no minimum size forces overlap.

css - flash objects overlap when window is resized? - Stack Overflow

css flash actionscript-3 html
Rectangle 27 0

Why not simply using percent width and height on your HTML page for your Flash object ? This way you event don't have to do anything to resize your SWF...

actionscript 3 - Strange behaviour when dynamically resizing Flash / F...

flex actionscript-3
Rectangle 27 0

I have found a workaround for my current problem.

I can add the following event handler to my sub-swf:

public function AddedToStage():void
{
    this.width = this.stage.width;
    this.height = this.stage.height;
}

and attach it to the addedToStage event of the application.

However, I would still like to know how to set the dimensions of the sub-swf from the parent swf - there may be times where I don't have control over the loaded swf so I can't add this code to it.

flash - Problem resizing loader after loading swf - Stack Overflow

flash actionscript-3 loader
Rectangle 27 0

You could generate the <object> tag which embeds the SWF file via JavaScript and print the width and height programmatically based on the size of the containing window. For example:

<script type="text/javascript">
  var w=window.innerWidth, h=window.innerHeight;
  document.write('<object width="' + w + '" height="' + h + '">');
  document.write('  <param name="movie" value="x.swf">');
  document.write('  <embed src="x.swf" width="100%" height="100%"></embed>');
  document.write('</object>');
</script>

The method for retrieving the window width/height will probably vary per browser but I'm sure you can find a reliable, cross-browser way to do it somewhere online.

If you need to dynamically resize whenever the window is resized then you can attach a handler to the window.onresize event which retrieves the necessary object and embed DOM elements and change their width and height properties. Probably. I haven't tested any of this.

Why would you do this instead of just embedding at size "100%"?

flash - How to resize a .swf file depending on screen size? - Stack Ov...

flash dreamweaver
Rectangle 27 0

public function loaderComplete(event:Event):void
  { 
      var content:MovieClip = MovieClip(event.currentTarget.content );

      //the dimensions of the external SWF
      var _width:int = content.width;
      var _height:int = content.height;

      // you have several options here , assuming you have a container Sprite
      // you can directly set to the dimensions of your container, if any
      if( container.width < _width )
          _width = container.width // and do the same for height

      // or you could scale your content to fit , here's a simple version
      // but you can check the height too or keep checking both value
      // until it fits
      if( container.width < _width ) 
      { 
          var scale:Number = container.width / _width;
          content.scaleX = content.scaleY = scale;
      }

      // when all done, you can add your content
      container.addChild( content );
  }

You could also check greensock.com , http://www.greensock.com/ they have a great set of Loading classes where you can specify the width & height of the content you want to load , set a container to load it into and even specify how you'd like the content to fit, saves you all the code above ;)

flash - How to resize an external SWF to fit into a container? - Stack...

flash actionscript
Rectangle 27 0

To my knowledge you can't do that. I can't actually fiddle around with it, 'cause i currently don't have access to flash.

It could work if you would insert the swf into a div, or whatever, that's "too big" for it in the first place, and then just try and resize it. What are you using to embed the swf, the basic thingie offered by the Flash IDE or something else, like swfobject?

I don't know, you might have to actually use ExternalInterface or something like that to get the job done. And if it's not terribly important to work the player into your web layout, i would just implement the whole thing in the flash movie.

flash - How do you make a SWF resize inside a HTML page? - Stack Overf...

html flash actionscript-3 flash-player