ActionScript.org Flash, Flex and ActionScript Resources - http://www.actionscript.org/resources
Set up a simple IIS Server for Flash
http://www.actionscript.org/resources/articles/768/1/Set-up-a-simple-IIS-Server-for-Flash/Page1.html
Peter McBride
A 20-year veteran of multimedia design, Pete has been working with Flash since its FutureSplash infancy, garnering numerous awards and recognitions along the way. Considered a pioneer in whatever-it-is we actually do, one of his earliest designs was recently placed in the Smithsonian Institution as a landmark point in the history of computing. In addition to Flash, Pete is an avid JavaScript and CSS addict, with a specialization in cross-language interaction. 
By Peter McBride
Published on April 28, 2008
 
Difficulty: Easy
Time Taken: 1-2 hours

Description: This is an interdisciplinary tutorial that shows how to install and set up a simple chat system in Flash, from the ground up, using IIS as a server and Access as a database. This tutorial is for intermediate Flash/Flex developers who wish to expand their toolset to include basic server and database setup and operation, but don't know how. Come in, get your feet wet... just avoid the deep end for now!

Setting up a Simple IIS Server for Flash... Step by Step
The purpose of this tutorial is to create a simple client-server system, centered around Flash, from the ground up. I will do my best to make no prior assumptions of knowledge on the part of the reader, other than access to basic hardware and software, and a general working knowledge of Flash and Windows.

We're going to create a Flash swf, running from a web browser, which communicates with an Access database via ASP.NET over IIS, on a WinXP Pro Service Pack 2 laptop. If you don't know some of those terms, or have heard of them but never used them, this tutorial is for you!

Warning:

This is not intended to be a robust chatroom application, nor is it even intended to show off good coding technique. For that matter, it's not even intended to be used, period, except to serve as a basic primer on the various technologies involved. Come on in and get your feet wet; just stay out of the deep end!

Why did I pick this particular combo?

One word: Availability – most Flash developers, particularly those in corporate environments, will have easy access to these items. You've obviously got Flash, or you wouldn't be reading this; Windows XP (and Vista) are on something like 85% of all personal computers, and already come with IIS and ASP.NET; and finally Access comes with Microsoft Office, which most people have.

I know... Windows Server, Linux or Apache make for far better servers; just about anything makes a better database than Access; and nobody in their right mind would use a laptop as a platform… but it's about 80% likely that right now, you're using a similar configuration to read this and want to try the examples without any hassle. Hence my choice.

In the spirit of setting up a faked "chat room" client-server application in Flash, we'll be setting the IIS/ASP/DB thing as a "queue server" in which each user has his or her own table in the database, to which other users can add messages consisting of a "code" and "data", e.g. "CHAT" and "Wassup, G?". The client simply grabs everything from his table periodically, and does analysis of the contents in Flash, clearing the table for any more submittals by other users. This is useful for simple peer-chats and simple games. The example shown is NOT robust, NOT efficient, and NOT recommended for any practical use; rather, it is an introduction to the installation and integration of the various technologies involved, so that you, the Flash developer, can get started doing Peer-to-Peer and Client-Server communications with only a minimal knowledge of the technologies involved.

In other words… there are better ways of doing this; this is just one of the simpler ways. If you figure a better/simpler/cooler way, share it. If you know how to do this with other technologies, share it. And when giving tutorials, PLEASE give details - not everyone knows what you assume to be common knowledge (see the "aspnet_regiis bugfix", below… server guys all know this one by heart, but it took me 2 hours of digging to realize it was in my .Net folder and needed to be run from the command prompt).

 

Assumptions:


You know Flash well enough to geek around with server/xml connections a bit, and are working on a WinXP/Vista machine with Microsoft Office already installed. Just in case, you should have your OS and Office installation disks handy, in case you need to load a component. For setup, a network connection may also be required, but is not necessary once installation is complete.

Corporate Users: If you are using a computer supplied by a corporation, rather than your own personal computer, you should be aware of two things:

  • System Administrators typically cripple certain system functions on corporate machines: some of the functionality you need may be unavailable, and some of the screens shown may not exactly match what you see here. If you experience any problems, please speak with your system admin to see if anything can be done.
  • Corporations typically frown upon employees creating their own websites, even if for business purposes. Be sure to check that you are not violating any security practices/policies before attempting this tutorial.




First Steps: Installation and Configuration (.Net, IIS, ASP, Access DB)

STEP ONE: SETUP
Create a folder on your hard drive that everything is going to go into; we'll refer to this as your "Dev" folder. It can be anywhere.

STEP TWO: INSTALLING .NET
Install .NET if you don't already have it (you may not need this at all as .Net often gets installed by other programs).

Go to Start: Control Panels: Add or Remove Programs 

In the list that appears, Look for "Microsoft

.NET Framework" followed by a version number. If you have Windows Vista installed, you are pretty much guaranteed to have at least Microsoft .NET Framework 3.0 (This tutorial is based off of .Net Framework 2.0, but should work in any version (I think)) It's common to have multiple versions, as shown below:



If you don't have it, no worries – just go to the Windows Update site http://www.update.microsoft.com, do a custom update and check off any .Net options. You may need to do this several times to get all the updates, etc. There's nothing to configure or worry about here; it's just tedious.


Step 3: Installing IIS
STEP THREE: INSTALLING IIS
Go to Start: Control Panels: Add or Remove Programs.
In the window that appears, click the Add or Remove Windows Components button in the left column. Scroll to "Internet Information Services" – if it's already checked, lucky you, go to Step Four. If not checked, check it and make sure "Network Services" is also checked (it's on by default), then click "Next". You'll probably be asked for your Windows installation disk, possibly even several times.



IIS is now installed, but if you're on Windows XP there's a good chance it doesn't work properly. When IIS is installed after .Net 2 is installed, any .Net 2 specific ASP calls will fail mysteriously. It's a common bug, and a real pain to diagnose unless you speak to someone who's already encountered it.

The fix: you need to run a small undocumented .Net utility that re-registers .Net with IIS. The utility is named aspnet_regiis.exe, and it is located under C:\Windows\Microsoft.NET\Framework\vx.y.zzzz\ (where x.y.zzzz is a version number) and you should call it with the -i parameter: aspnet_regiis.exe –i from a command prompt.

The easiest way to do this is to navigate to c:\Windows\Microsoft.NET\Framework\. Inside you'll see several folders starting with a "v" followed by several numbers, which represent the various framework versions. Pick the v2.whatever folder (on mine it's v2.0.50727) for WinXP. (Vista users should choose the v3.xxx folder, but I'm not sure if the bug affects you anyway, so check elsewhere for details)



Inside this folder you'll find the aspnet_regiis.exe file. Verify that the file is really there, but don't try to run it - it's just a DOS app.

Instead, we want to copy the full address path of the file. Select the address field, and copy it to the clipboard (ctrl-C or right-click and select Copy).



If you don't have the address field showing, you can also r
ight-click the aspnet_regiis.exe file, and click Properties. Select the entire "location" field, and copy that text instead.


Now go to Start: Run, and Paste the address into that field. Just after that, type \aspnet_regiis –i and click OK. On my machine, the full line would look like this:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis –i


This takes a minute or so to run, and fixes the bug.

To verify everything is working, open up IE or Firefox and enter http://localhost/ in the URL field. If you get either a "403" error or some kind of bland "you should really have a webpage" kind of remark, it's working. If the error is a "404" or any number higher than 500, there's a good chance something's unhappy with the security configuration on your computer, and you should seek a system administrator for further help.

IIS is now installed, but needs to be configured.


Step Four: Configuring IIS
You're now ready to configure IIS. We're going to set up something called a "virtual directory" that points to your Dev folder, so that when you type in http://localhost/dev/ you'll be served up the contents of that folder. That's basically what a virtual directory is – it's a directory in a URL that refers to

Go to Start: Control Panel: Administrative tools: Internet Information Services. Welcome to IIS.

Expand your (local computer) on the Tree view on the left, then expand "Web Sites". Right-click "Default Web Site" and select "New> Virtual Directory…"

Enter an Alias – this is the name of the folder as it will appear in a url, ie to create http://localhost/devtest/ you'd just enter "devtest". Hit Next, then hit the Browse button and point to that Dev folder we created in step one. When Access permissions appears, select "Read" "Run Scripts" and "Write" (I'm not sure about Write, but heck, this is development, not production).

IIS is now configured, and anything you throw into your dev folder is now available in a browser at url http://localhost/devtest/ or from other machines at http://(your ip address)/foo/ (Okay, figuring out your ip address so others can see you is a lesson in itself!)

BUT… we're only halfway there. This is a database application, so we need to grant network write permission to the folder your files are stored in. To do this, right-click your Dev folder from step one, select "Properties" and go to the "Sharing" tab. Check "Share this folder on the Network" and "Allow network users to change my files". Depending on your system, something similar may show up, but you get the general gist of it. This allows the data base to be written to via the network.