Tải bản đầy đủ (.pdf) (8 trang)

Tài liệu Understanding and Using fscommand() pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (30.77 KB, 8 trang )


< Day Day Up >


< Day Day Up >

Understanding and Using fscommand()
fscommand() is a function that enables a Flash movie to communicate with the
application that's currently holding the movie. The following are examples of
applications that hold (host) Flash movies:

Standalone Flash player

Web browser

Executable that displays the Flash movie, such as those created by third-party
tools discussed later in this lesson; or executables created using C++, Visual
Basic, and so on
It's simple to use an FSCommand from within Flash. The fscommand() function accepts
two parameters: a command name, and optional extra information. The extra information
is used as a parameter of the command:

fscommand("command_name", "optional extra stuff");


When Flash executes an fscommand(), the host application receives notification that a
command has been sent to it. The name of the command is sent, as well as any optional
parameter data. The host application must be programmed to deal with these incoming
commands; it looks at the name of the incoming command and reacts accordingly, using
any optional parameter data to complete the task. This functionality will become clearer
as we progress in this lesson.



< Day Day Up >


Let's explore in detail some of the previously mentioned uses of the fscommand()
function.
Controlling the Standalone Flash Player (Projectors)
Using the Publish settings in Flash, you can publish a Flash movie as a projector. A
projector file typically contains your movie as well as the Flash player. Opening the file
causes your movie to play in its own application window (the Flash player/Projector
window). The fscommand() function can be used in your movie so that it can
communicate with the projector in various ways. There are six built-in FSCommands that
the standalone player can execute:

fscommand("quit")


This command closes the standalone player window.

fscommand("fullscreen", true)


< Day Day Up >


or

fscommand("fullscreen", false)



This command forces the standalone player to play at full screen (if true) or at the defined
movie size (if false).

fscommand("allowscale", true)


or

fscommand("allowscale", false)


This command determines what happens if the user resizes the projector window while
your movie is playing. If true, the movie is scaled to fit 100% in the resized standalone
player window. If false, the player window is still resizable, but the movie playing inside
it remains at its original size.

fscommand("showmenu", true)


or

fscommand("showmenu", false)


Right-clicking (Control-clicking on a Macintosh) a movie playing in the standalone
player opens a context menu. The minimal version of this menu is shown if this

< Day Day Up >

fscommand() parameter is set to false. The full menu is shown if true.


fscommand("exec", fileName)


This command executes (opens) another application (such as an .EXE file on Windows).
The parameter is the filename of the application to open. Applications opened using this
command must reside in a folder named fscommand. This folder must reside in the same
directory as the projector.


fscommand("trapallkeys", true)


or

fscommand("trapallkeys", false)


If true, all key events are sent to the Flash player. If false, certain key events such as
accelerator keypresses are not sent.
Any of these commands can be executed from within your movie using syntax similar to
the following:

myButton_btn.onRelease = function(){

fscommand("quit");

}



Standalone FSCommands have no effect on Flash movies played outside the stand alone

< Day Day Up >

player.
Executing Applescripts with Fscommands
AppleScript is a built-in scripting language for the Macintosh operating system.
AppleScripts (files containing AppleScript code) are used to tell the operating system to
perform tasks such as these:

Batch processing

File conversion and manipulation

Performing tasks at specified times
One of the more powerful aspects of using the exec FSCommand in a Macintosh-based
projector is its capability to execute an AppleScript. Let's look at a simple example.
NOTE
This is not intended to be extensive instruction on how to create AppleScripts, but rather
a simple demonstration of how AppleScripts can be executed via Flash. For more
information on AppleScript, visit />.

The following AppleScript opens the file named catalog.pdf on the My CD disk:

tell application "Finder"

activate

select file "catalog.pdf" of disk "My CD"


open selection

end tell


To execute this AppleScript from Flash, you name it (for example, launchCatalog), save
it in the fscommand folder, and create a script within your Flash movie similar to the
following:

myButton_btn.onRelease = function(){

×