


Here is the solution in form of an architecture picture. To simplify: we will trick the Flash Player by calling a .bat file placed in a directory named fscommand. This .bat will then call an .exe that will catch the window handle (over C#) of your Flash Player and then resize the Flash Player window. Tricky, isn’t it? It’s the only way to realize this and here is the step to step tutorial.

Step 1: fscommand

One command that is available in Flash Player to communicate with the operating system is fscommand. With fscommand you can start any .bat (not exe) placed in a directory named fscommand. So now we can write following AS3 code:

function resizeFlashPlayer(aHeight:int,aWidth:int):void
trace("Now resizing to: " + aHeight + " // " + aWidth);
var executeCommand:String = "resize_"+ aHeight + "x" + aWidth + ".bat";
fscommand("exec", executeCommand);

But why using a concatenated string to build the path to .bat ?

Content of the /fscommand directory

The problem with fscommand is that you cannot pass a variable to .bat. It also means that you will need to generate a .bat for each screen resolution. But come on, it’s not a major issue ;-) Here is the swf we are going to build to test the whole workflow. You can download the whole project at the end of this post.

Screenshot of the Flash Player with our SWF test file

Step 2: Setting the .bat file

The .bat will help us to launch an exe. Why using a .bat and not directly the exe? fscommand doesn’t allow to directly launch the exe, so we are using a .bat as what can be called a proxy. Here is the content of the .bat file (named rezise_800x600.bat):

@echo off
start /b ResizeFlashPlayer.exe 800 600

Step 3: Creating the ResizeFlashPlayer.exe with C#

Here comes the trickiest part. In order to be able to control the Flash player we are going to use C# and the SetWindowPos function to resize our window. In order to find the Flash Player we are going to crawl over the processes of Windows and catch every window title name. When we have found the window with the name “Adobe Flash Player 10” we have found the currently running Flash Player instance. Once found we can then use a pointer on it and apply the SetWindowPos function that will allow to set the width (cx) and height (cy) of the window.
In order to have some more flexibility, I’ve choosen to pack it as a ConsoleApplication and to use two arguments (remember that we are calling ResizeFlashPlayer.exe over a .bat).

namespace ConsoleApplication
{ class Program {
static void Main(string[] args)
{ Process[] processes = Process.GetProcesses(); foreach (Process p in processes) { if (p.MainWindowTitle.IndexOf("Adobe Flash Player 10") != -1) { IntPtr pFoundWindow = p.MainWindowHandle; Debug.WriteLine("Flash Player was found"); if (1 < args.Length) { if (args[0] != null && args[1] != null) SetWindowPos(p.MainWindowHandle, 0, 0, 0, Int16.Parse(args[0].ToString()), Int16.Parse(args[1]), 0); } } } } }

Step 4: Publish and build with the Flash Player Projector

Last step: Open the Flash Player (, select your .swf and click on create a Projector. This will generate a projector for your swf: press one of the buttons and you will see how the Flash Player will directly resize!

That’s it! Enjoy the code and if you want to test it, download the code below

Download the code of the C# and the Flash example application