JavaScript

Provides extended JavaScript functionality for the BNMAPI above and beyond standard ExternalInterface functionality.  Also used extensively by sub-classes like the <com.bnm.api.Events> class.

JavaScript functionality is only available if the current runtime environment supports it.  If not, any JavaScripts-specific properties and methods will be disabled.

__/ REQUIREMENTS \__

ActionScript 3.0 (or later)

__/ IMPORTS \__

com.bnm.api.instances.ErrorBroadcast com.bnm.api.instances.Exception flash.external.* com.bnm.api.Payloads flash.xml.*

__/ EXTENDS \__

com.bnm.api.Introspection

__/ IMPLEMENTS \__

nothing

__/ NOTICE \__

©opyright 2008 Bay New Media.  All rights, as stipulated in the The MIT License, are reserved.

This ActionScript library is licensed and released under the MIT License (http://www.opensource.org/licenses/mit-license.php).  Please refer to the accompanying text file “license.txt”, which should be distributed with every package and version of this library, for information on usage, distribution, copying, and other important information.

Please visit http://www.baynewmedia.com/ or email con.nosp@m.tact@baynewm.nosp@m.edia.com for information, questions, concerns, or bug reports.

__/ NOTES \__

This class is commented using the NaturalDocs documentation system.  It is intended to be easily read both from the direct source code and from an adaptation that is generated as hyperlinked HTML.  The NaturalDocs specification used in this class’ documentation is version 1.35 though older versions may probably be used safely.  For more information, please visit: http://www.naturaldocs.org/

The BNMAPI is officially available (primary sources) on Source Forge (http://sourceforge.net/projects/bnmapi/), on the Bay New Media site (http;//www.baynewmedia.com/), on the PeaBee project site (http://www.peabee.com/), and through the Bay New Media SVM repository server (visit http://www.baynewmedia.com/ for more information).  Downloads from other sources may not be complete or up-to-date.

If you’re interested in joining the BNMAPI project in any capacity (development, testing, distribution, etc.), please visit us on Source Forge or the Bay New Media web site.

Summary
JavaScriptProvides extended JavaScript functionality for the BNMAPI above and beyond standard ExternalInterface functionality.
Variables
JavaScript_available(Boolean) Stores whether or not JavaScript is available in the current runtime environment.
Functions and Properties
EventsConstructor method for the class.
JavaScript
alertCreates a JavaScript `alert` box if JavaScript is available in the current runtime environment.
get JavaScriptAvailableReturns the state of the internal static JavaScript_available property.
JavaScriptAvailable
checkJavaScriptEnvironmentChecks the runtime environment for JavaScript availability as well as running some simple tests to determine what JavaScript functionality is available.
injectJavaScriptInjects JavaScript code into the current web page for later execution.
getExtendedEnvironmentInformationCalled only if the environment is determined to be JavaScript capable; queries the JavaScript environment for various pieces of information and appends them to the <com.bnm.api.CoreObject> class’ `environment` object.

Variables

JavaScript_available

private static var JavaScript_available: Boolean

(Boolean) Stores whether or not JavaScript is available in the current runtime environment.  Will be TRUE if the application is running in a web-based player, FALSE otherwise (default).  A getter is provided for external access.

Functions and Properties

Events

Constructor method for the class.

Parameters

none

Returns

JavaScript: A reference to the newly created class instance.

Broadcasts

nothing

Throws

nothing

Bubbles

no

See also

<init> <setDefaults>

JavaScript

public function JavaScript ()

alert

public function alert (alertMessage: *,
... args):void

Creates a JavaScript `alert` box if JavaScript is available in the current runtime environment.

Parameters

alertMessage (untyped, required): The message to send to JavaScript alert dialog.  May be any type; if it’s not a String type, it will be converted. bypassDetection (Boolean, optional): Bypasses runtime environment detection.  This should only be used if it’s suspected that the API is incorrectly detecting the runtime environment and it is desired to force display of the alert dialog.  FALSE is default.

Returns

nothing

Broadcasts

nothing

Throws

nothing

Bubbles

no

get JavaScriptAvailable

Returns the state of the internal static JavaScript_available property.

Returns

Boolean: TRUE if JavaScript functionality is available in the current runtime environment, FALSE otherwise.

Broadcasts

nothing

Throws

nothing

Bubbles

no

JavaScriptAvailable

public function get JavaScriptAvailable ():Boolean

checkJavaScriptEnvironment

public function checkJavaScriptEnvironment ():void

Checks the runtime environment for JavaScript availability as well as running some simple tests to determine what JavaScript functionality is available.  This method is intended to be incoked by the BNMAPI instance since it requires a number of references and member variables (especially in super classes) to be present.

Parameters

none

Returns

nothing

Broadcasts

nothing

Throws

nothing

Bubbles

yes

injectJavaScript

public function injectJavaScript (code: String):void

Injects JavaScript code into the current web page for later execution.  This is accomplished via the JavaScript “eval” method and may therefore be used for almost any functionality.  However, if there is an error in the JavaScript injection code it will fail, so it is advisable to break up injections into smaller chunks.  Note that injection does not report errors so it is imperative that any JavaScript code used is thoroughly tested.

Parameters

code (String, required): The JavaScript source code to inject into the current web page.

Returns

nothing

Broadcasts

nothing

Throws

nothing

Bubbles

no

getExtendedEnvironmentInformation

private function getExtendedEnvironmentInformation ():void

Called only if the environment is determined to be JavaScript capable; queries the JavaScript environment for various pieces of information and appends them to the <com.bnm.api.CoreObject> class’ `environment` object.  New properties “browser” and “javascript” are added to the `environment` object for this purpose.

Parameters

none

Returns

nothing

Broadcasts

nothing

Throws

nothing

Bubbles

yes

The Introspection class is used to analyze, or “introspect”, a running application.
The Events class is the heart of the BNMAPI.
private static var JavaScript_available: Boolean
(Boolean) Stores whether or not JavaScript is available in the current runtime environment.
public function JavaScript ()
public function alert (alertMessage: *,
... args):void
Creates a JavaScript `alert` box if JavaScript is available in the current runtime environment.
public function get JavaScriptAvailable ():Boolean
public function checkJavaScriptEnvironment ():void
Checks the runtime environment for JavaScript availability as well as running some simple tests to determine what JavaScript functionality is available.
public function injectJavaScript (code: String):void
Injects JavaScript code into the current web page for later execution.
private function getExtendedEnvironmentInformation ():void
Called only if the environment is determined to be JavaScript capable; queries the JavaScript environment for various pieces of information and appends them to the com.bnm.api.CoreObject class’ `environment` object.