473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Shortcut to Class Method fails in firefox, works in IE.

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 ExternalInterface.addCallback("TestFunction",this, TestFunction) ... what it does is not important. The failure is in calling it:


Code:
Expand|Select|Wrap|Line Numbers
  1.     function thisMovie(movieName) {
  2.         if (navigator.appName.indexOf("Microsoft") != -1) {
  3.             return window[movieName];
  4.         }
  5.         else {
  6.             return document[movieName];
  7.         }
  8.     }
  9.  
  10.     var MyObject = new Object();
  11.     MyObject.SWF = thisMovie("TestMovie");
  12.  
  13.     // This works in all browsers:
  14.     MyObject.SWF.TestFunction();
  15.  
  16.     // Works in IE, but crashes in Firefox:
  17.     var wtf = MyObject.SWF.TestFunction;
  18.     wtf();
  19.  
Jan 24 '08 #1
3 1737
acoder
16,027 Expert Mod 8TB
I can't see any reason why it fails in Firefox/Safari. I think the term you're looking for might be function objects. You might find this article useful.
Jan 24 '08 #2
I can't see any reason why it fails in Firefox/Safari. I think the term you're looking for might be function objects. You might find this article useful.
Thanks. After extensive testing, the issue appears to be in the interface between the Flash plugin and Firefox; when performing a GetObjectByID on the object, it incorrectly interprets the DOM object as being a function, despite actually being an htmlEmbedElement. IE however, interprets the Flash Player as an a proper Object (because it sees the Object, not the Embed).

I'm not sure who's to blame here... Adobe's interface or Mozilla for creating what's essentially a third classtype. Google shows less than 3500 entries for "htmlEmbedElement", so my guess is that this is probably a scenario Adobe/Macromedia/Mozilla never thought of.

The plugin, at the lowest level, only communicates with Javascript in JSON-like strings. Adobe injects quite a bit of hidden javascript into the page for conversion of Primitives ad Objects into a string, allowing more complex objects to "pass" across the barriers. they go across as strings, and are then reconstituted into their native Primitives, which is why functions and scoped objects cannot be passed. (Okay, passed EASILY).

I suspect the pseudo-JSON converter gets confused when being handed a htmlEmbedElement as opposed to an Object, Function, or Primitive, and is sending the actual object, not a string, across to the plugin, causing the crash.

Hopefully this defect will be addressed in a future release of the plugin, although it's so obscure that I'm nt holding my breath. In the meantime, I'm using a different method to get similar results.
Jan 30 '08 #3
acoder
16,027 Expert Mod 8TB
I'm not sure about this, but do the embed and object have the same name?
Jan 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: aa | last post by:
Thought this question might be out of this NG's scope, there are always knowledgable people who might hava an answer. A hyperlink to a shortcut to a file returnes an empty screen, and the source...
2
by: Phil Green | last post by:
Hi, I have been creating a CD-based site which works exactly how I want in IE5. I decided that I should test it in Mozilla Firefox and Opera. Unfortunately, a lot of the scrips don't work as...
14
by: David Blickstein | last post by:
I have some XML documents that I want to open in a web browser and be automatically translated to HTML via XSLT. I'm using an xml-stylesheet processing command in a file called "girml.xml". ...
0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
7
by: SevDer | last post by:
Hi I have a class library that needs to download the HTML in a specific page of ours with provided querystring. When I open this URL with any browser, it loads fine. When I do WebRequest from Web...
7
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. ...
5
by: HopfZ | last post by:
I made two shortcut functions for document.getElementById as: function EBI2(id){return document.getElementById(id)}; var EBI3 = document.getElementById; But EBI3 don't work. EBI2('myText');...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
3
by: KennethLundin | last post by:
Hi, i'm developing a solution in VS9/CSharp. Now I'm constructing a deployment project for my appliation (thick, database driven, winforms, standard, good old type of application). During...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.