beyond flash. bridge. bridge. the browswer. red image.
home. intro. content. about. contact.    
           
  chapter 1.    
  chapter 2.  


Chapter 1: ACTIONSCRIPT COMMAND LINES

The easiest and most popular way for a Flash projector to communicate with the outside world is through the EXEC command actionScript, which allows you to launch external applications. The way you pass parameters to these applications is on the command line. That makes it important to know what you can do with command lines. If you just said 127 characters and tuned out, tune back in, we're about to shatter a myth.

Back in the old days when memory was incredibly expensive, people went to great lengths to conserve it. Whenever you started a DOS application the command processor (what we call the DOS box now) created a 256-byte data structure in memory called a program segment prefix (PSP). All the information a new program
needed to orient itself was contained in the PSP. The last 127 bytes of the PSP were used to hold everything that appeared on the command line after the application name.


Click for larger view


Backward compatibility with the PSP is why Windows 3.11 and early versions of the NT command processor only allowed you to specify 127 characters of arguments on a command line. The newer command processors still have
limitations but it's higher than 127 characters.

 


Our experiments with Windows 95, 98, and ME show that it's possible to pass up to 485 characters and on Windows NT, 2000 and XP you can pass up to 2046 characters (2 bytes less than 2K). Both of these numbers represent the entire command line, including the application path and file name. That's a far cry from 127 characters but... we have even better news. These limits only apply when you use a command processor (DOS
box) to start these applications and Flash doesn't use a DOS box.

When you use the Flash EXEC command actionScript to start an application, Flash makes use of a Windows API function called CreateProcess. One of the arguments to CreateProcess is a buffer that holds the command line. This buffer CAN be as large as available memory. But to keep things from getting too crazy, Flash puts limits on the amount of data that EXEC will handle. Once again, these limits are a LOT higher than you might think they
are.

Under NT, 2000 and XP EXEC will let you pass 32768 bytes, that's 32K, and this time 95, 98 and ME come out ahead. We tested this for a while and never really found the limit. The last test we performed sent 300K through the EXEC command actionScript without any problems. We think this is just because the CreateProcess function doesn't really exist on these systems; it's implemented using an older API function called WinExec that doesn't do the same strict buffer checking that CreateProcess does. To be safe, and to ensure your projector works on all systems, you shouldn't try to pass any more than 32K to EXEC. If you have even one more character than EXEC can handle, the command line won't be truncated… the application doesn't even get called!

We have a little example program that we can use to demonstrate this. The Flash application (.FLA) and the C source code for all the examples we show you will be available from our web site for anyone that wants to play
with this on their own.

 

 
  chapter 3.
  chapter 4.
  chapter 5.

 

This site is
sponsored by:

www.northcode.com