Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Making FABridge global variables really global.

When concatenating FABridge with other scripts into one big .js file,
it can happen that the FABridge.js code is no more run in global scope,
and when that happens the functions defined in FABridge.js won't be
global, most importantly those functions that Flash wants to call
that really have to be global.

The standard practice in JavaScript libraries is to add that kind
of functions directly to the window object.  This is what I have
done here.

Additonally renamed instanceFactory() into FABridge__instanceFactory().
And made the accidental gobal variable newType into local variable.
  • Loading branch information...
commit 28f955d5747df3979b11aa5700e5104a933ff6b4 1 parent 6234403
@nene authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 FABridge.js
View
16 FABridge.js
@@ -20,7 +20,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* The Bridge class, responsible for navigating AS instances
*/
-function FABridge(target,bridgeName)
+window.FABridge = function(target,bridgeName)
{
this.target = target;
this.remoteTypeCache = {};
@@ -67,13 +67,13 @@ FABridge.argsToArray = function(args)
return result;
}
-function instanceFactory(objID)
+window.FABridge__instanceFactory = function(objID)
{
this.fb_instance_id = objID;
return this;
}
-function FABridge__invokeJSFunction(args)
+window.FABridge__invokeJSFunction = function(args)
{
var funcID = args[0];
var throughArgs = args.concat();//FABridge.argsToArray(arguments);
@@ -102,7 +102,7 @@ FABridge.addInitializationCallback = function(bridgeName, callback)
}
// updated for changes to SWFObject2
-function FABridge__bridgeInitialized(bridgeName) {
+window.FABridge__bridgeInitialized = function(bridgeName) {
var objects = document.getElementsByTagName("object");
var ol = objects.length;
var activeObjects = [];
@@ -348,8 +348,8 @@ FABridge.prototype =
createProxy: function(objID, typeName)
{
var objType = this.getTypeFromName(typeName);
- instanceFactory.prototype = objType;
- var instance = new instanceFactory(objID);
+ FABridge__instanceFactory.prototype = objType;
+ var instance = new FABridge__instanceFactory(objID);
this.remoteInstanceCache[objID] = instance;
return instance;
},
@@ -362,7 +362,7 @@ FABridge.prototype =
// accepts a type structure, returns a constructed type
addTypeDataToCache: function(typeData)
{
- newType = new ASProxy(this, typeData.name);
+ var newType = new ASProxy(this, typeData.name);
var accessors = typeData.accessors;
for (var i = 0; i < accessors.length; i++)
{
@@ -570,7 +570,7 @@ FABridge.prototype =
// The root ASProxy class that facades a flash object
-ASProxy = function(bridge, typeName)
+window.ASProxy = function(bridge, typeName)
{
this.bridge = bridge;
this.typeName = typeName;
Please sign in to comment.
Something went wrong with that request. Please try again.