I have a static class method, MyObject.MySub. MyMethod(), which points to a handler in a Flash SWF (but I think that's inconsequential ). In reality, the path is a lot longer, so I'd like to make a simpler way for other programmers to access that method, such as this:
var MyFunc = MyObject.MySub. MyMethod
So they could just call MyFunc() instead. This "proxy" or "shorthand" works great in IE, but fails in Firefox/Safari and sometimes even crashes, saying it's an "illegal operation".
Two questions:
1) Is there a technical name for creating a simplified "pointer" to an existing function, so I can research this issue more easily, and.
2) Anybody got a clue as to why Firefox and Safari Crash, but IE accepts this and works fine? Is there a better way to do this?
Code sample follows:
Javascript Code follows. Movie "TestMovie" is a SWF containing ExternalInterfa ce.addCallback( "TestFunction", this, TestFunction) ... what it does is not important. The failure is in calling it:
Code:
var MyFunc = MyObject.MySub. MyMethod
So they could just call MyFunc() instead. This "proxy" or "shorthand" works great in IE, but fails in Firefox/Safari and sometimes even crashes, saying it's an "illegal operation".
Two questions:
1) Is there a technical name for creating a simplified "pointer" to an existing function, so I can research this issue more easily, and.
2) Anybody got a clue as to why Firefox and Safari Crash, but IE accepts this and works fine? Is there a better way to do this?
Code sample follows:
Javascript Code follows. Movie "TestMovie" is a SWF containing ExternalInterfa ce.addCallback( "TestFunction", this, TestFunction) ... what it does is not important. The failure is in calling it:
Code:
Code:
function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName]; } else { return document[movieName]; } } var MyObject = new Object(); MyObject.SWF = thisMovie("TestMovie"); // This works in all browsers: MyObject.SWF.TestFunction(); // Works in IE, but crashes in Firefox: var wtf = MyObject.SWF.TestFunction; wtf();
Comment