Recipe 2.8. Dispatching EventsProblemYou want to dispatch events. SolutionExtend flash.events.EventDispatcher and call the dispatchEvent( ) method. Discussion
Events are an important way for objects to communicate. They are essential for creating flexible systems. Flash Player 9, for example, has a built-in event dispatching mechanism in the
flash.events.EventDispatcher
class. All classes that dispatch events inherit from
EventDispatcher
(e.g.,
NetStream
and
Sprite
). If you want to define a class that dispatches events, you can extend
EventDispatcher
, as
package {
import flash.events.EventDispatcher;
public class Example extends EventDispatcher {
}
}
The
EventDispatcher
class has public
|
Chapter 3. Runtime Environment
Section 3.0. Introduction Recipe 3.1. Detecting the Player Version Recipe 3.2. Detecting the Operating System Recipe 3.3. Checking the Player Type Recipe 3.4. Checking the System Language Recipe 3.5. Detecting Display Settings Recipe 3.6. Scaling the Movie Recipe 3.7. Changing the Alignment Recipe 3.8. Hiding the Flash Player's Menu Items Recipe 3.9. Detecting the Device's Audio Capabilities Recipe 3.10. Detecting the Device's Video Capabilities Recipe 3.11. Prompting the User to Change Player Settings Recipe 3.12. Dealing with System Security |
3.0. Introduction
Flash Player 9 offers a relatively large amount of information about and control over the runtime environment. The
flash.system.Capabilities
class has many static
Perhaps one of the most significant updates to Flash Player 7 within this chapter's subject matter is the ability to work with the context menu with more detail and precision than was allowed in previous versions of the player. In Flash Player 7, using the
ContextMenu
class, you can programmatically remove items from the context menu, and perhaps more importantly, you can add items to the menu. And as the
|
Recipe 3.1. Detecting the Player VersionProblem
You want to ensure that the
SolutionUse the Flash Player Detection Kit, available on Adobe's web site to check the version of player and, if necessary, initiate a player upgrade (http://www.adobe.com/software/flashplayer/download/detection_kit). Discussion
Detecting the currently installed version of the Flash Player in the user's browser has been a problem for
The first method uses JavaScript or VBScript to detect the version of the Flash Player the user has installed. Many of these scripts were prone to errors due to differences in platforms and browser types. Server-side detection can be difficult if you don't have the ability to create server-side scripts.
Most ActionScript-based player detection techniques won't work directly in an ActionScript 3.0-based
.swf
. While ActionScript 1.0 and 2.0 had various object
Adobe has researched all of these issues thoroughly, and came out with a Flash Player Detection Kit that guides you through the recommended procedures for best detecting the player version. The kit includes documentation on the various issues and potential solutions, including sample VBScript and JavaScript for browser-based detection; .flas , .as , and .swf files for ActionScript detection; as well as ColdFusion and PHP scripts for server-side detection. ActionScript-based detection works successfully as long as the user has any version of the Flash Player from Version 4 on up. Basically, it is a Flash 4 .swf that executes a script to detect the current player version; all you need to do is set your minimum content version as a variable in the script. If the player version is at least as high as the content version, it loads the specified content. If not, it redirects the browser to an alternate content page. This page can contain a lower version .swf , a non-Flash version of the content, or a notice instructing the user to upgrade his Flash Player, with a link to the player install page on Adobe's site.
Furthermore, the kit contains a
.swf
and HTML template that initializes an Express Install of the latest version of the Flash Player. If the user's player is not adequate, the browser is redirected to this
.swf
, which downloads the latest version of the Flash Player from Adobe's site, automatically
Using a combination of the techniques included in the Flash Player Detection Kit gives you very precise control over the Flash Player version and the content you deliver to your
For testing purposes, older versions of the Flash Player can be obtained from Macromedia's site (http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14266). |