public function getTextId():String
{
return val;
}
ExternalInterface.addCallback("getId", getTextId);
I am getting the following error:
Access of undefined property getTextId.
ExternalInterface.addCallback("getId", getTextId);
But I have getTextId defined and all the tutorials indicate this is the correct method to do it.
Is your call to ExternalInterface.addCallback() inside of a method, or are you calling it a the "class level" (for lack of a better term), as shown in your code snippet?
I just tried adding the callback outside of a method, it worked... not surprised but I rarely code that way. However, I added second method as a callback, and got the same error as you at compile time.
Strange that it works for one method but not the other (no matter what I seem to try).
Have you tried moving the addCallback line into a function or the constructor? This fixes the error for me.
Related
Looking for help writing an interface that has a property (or function) that returns an object typed as a "Form" (e.g. Access.Form as the return type).
Problem description:
The following simple example code returns a "User-defined type not defined" error if I attempt to compile the project.
I_TestInterface:
Public Property Get MyForm() as Form
End Property
cls_TestClass:
Implements I_TestInterface
Public Property Get I_TestInterface_MyForm() as Form
End Property
This is the only code/objects in a otherwise blank Access-2016 database and asking VBA to 'compile' produces a "User-defined type not defined" error. No lines are highlighted, it simply won't compile. Same occurs if replace 'Form' by "Access.Form"
My usecase is writing classes that wrap/hold a reference to a form internally - sometimes it is easiest to provide a reference to the underlying form so that consuming code can get at form properties without coding them all into the wrapper class.
Steps taken:
Lots of searches on 'user-defined type not defined' errors, in almost all cases this is due to a missing reference. Does not seem applicable since can create a standard module and happy to compile if write a function with a Form return type there. (*)
There was one previous SO thread on similar 'ambiguous' 'user-defined type not defined' error but I can't find it again and it wasn't specific to the 'Form' type in MS-Access
Have a clumsy workaround of providing property that returns an Object type that consuming code just has to cast to a Form (e.g. public property get MyFormAsObjectThatCanBeCastToForm() as Object).
(*). Possible clue? - if I just change the return types to object, the code still won't compile. I need to exit and use the 'de-compile' start up switch when relaunch Access. Then the above code with Object used as a return type is happily compiled.
Question / request:
Before I start re-installing Office, can others reproduce this?
Has anyone experienced this before? Developed a solution?
Thanks
PAHTDC
Now I know why I avoid libraries like should that modify the object prototype
It looks like I get this error:
TypeError: Converting circular structure to JSON
when I require('should')
Is this expected?
before calling JSON.stringify, I can delete the properties from the object to be stringified like so:
delete obj.should;
delete obj.getShould;
but this is hard to do with nested objects etc. I have to say, this is pretty lame that should causes this, but maybe I am doing something wrong. How to fix this problem? I am writing a library and the user might require('should') so I have to protect against this type of issue.
Though with slightly different output, util.inspect() provides output without circular reference breaking it. Also it provides means to customize the object inspection. Will it work for you?
Should is not setting properies directly on the object, but rather on it's propotype:
Object.defineProperty(Object.prototype, 'should', {
set: function(){},
get: function(){
return should(this);
},
configurable: true
});
It must be something else that prevents an object from being serialized.
I have been working in this error for days, i keep searching and asking for help, (including reading from this site as well). It is basically involved a lot of external actionscript.
Every time i finish the interactive and i want to go back to previous frame, the error goes:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at pizzaBaking/doRESTART()
and this is the doRESTART function
public function doRESTART(e:MouseEvent):void{
MovieClip(parent).gotoAndPlay(131);
MovieClip(parent).MENUS.visible = false;
MovieClip(parent).ABOUT.visible = false;
MovieClip(parent).VOUCHER.visible = false;
MovieClip(parent).UPDATES.visible = false;
Due to quite a few of file, i put it all in mediafire, in flash cs6 http://www.mediafire.com/download/10skpaizeyk2kul/pizzaHut.rar
thank you so much
1: Turn on Debugging
Go to your publish settings and enable "Permit Debugging". This will take your ambiguous error...
null object reference at pizzaBaking/doRESTART()
...to a much clearer...
null object reference at pizzaBaking/doRESTART() script\pizzaBaking.as:35
...which now denotes which line in your code to look for your issue.
2: Use the Debug Console
Use the debugging compile mode to bring up the Debug Console. This will provide you with an immediate look at the line of code in question, as well as the Call Stack, and the state of all available Variables. No programmer should be without one.
3: parent == null
When doRESTART() is being called, it no longer has a parent, ergo, when you call MovieClip(parent) it returns a null, and there is no MENUS property on null. This is why it's reporting null object reference.
If I were you, I'd seriously reconsider how you're approaching this. Remove all timeline code, and any use of frame animation. This is likely the reason why your pizzaBaking class lost its parent relationship. Also, there appear to be several instances in which you could consolidate repetitious code into a single function (KeyboardPizza.as being a prime example). Consider passing a method an argument to modify its behavior, or use switch case, or perhaps a lookup table.
That said, press on. It looks like you're making great progress on your project.
-Cheers
In a plug-in I am using NPN_Evaluate() to execute some Javascript. How can I detect wether the Javascript raises an exception? Basically I want to execute any piece of Javascript and get the result from it or detect if it raised an exception.
I tried wrapping my Javascript code like this:
try {
// Injected Javascript code here
}
catch (exc) {
exc;
}
That way the result from NPN_Evaluate() will be an NPObject* containing a property "message" with the exception message if something goes wrong. But how can I know that it is an exception? It might as well be a result from the injected Javascript code.
Am I approaching this the wrong way? Can I detect an exception without catching it in Javascript and returning the exception as the result?
Personally I've never been a fan of using NPN_Evaluate; If I needed to do something that couldn't be done using other methods (NPN_Invoke, NPN_GetProperty, etc) I'd use NPN_Evaluate to inject a javascript function into the DOM and then call it using NPN_Invoke; then if it returns false you know it failed. There isn't any really good exception handling across that bridge, unfortunately, but the return value of true or false will tell you if it succeeded -- I suspect this holds true even for just using NPN_Evaluate.
Remember that anything declared global in javascript is a property of the window; thus, if you inject "function foo(bar) { alert(bar); }" with NPN_Evaluate you can use NPN_GetValue to get the Window NPObject and then call GetProperty("foo") to get the foo function. You can then call InvokeDefault on that bar method to call it, passing in whatever value you want for bar as a parameter.
Trying to implement the new FP 10.1 Global error handler into my projects but no matter what I do any uncaught error will still show up the Exception window (both in debug and release versions of the SWF). All I want to do is to prevent these popups but instead send a message to my logger. Here's my code ...
EDIT: I simplified the code now. Could somebody do me a favor and test the following class and see if it's works for him? Because it's doesn't for me! ...
package
{
import flash.display.Sprite;
import flash.events.UncaughtErrorEvent;
public class GlobalErrorHandlerTest extends Sprite
{
public function GlobalErrorHandlerTest()
{
stage.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
throw new Error();
}
private function onUncaughtError(e:UncaughtErrorEvent):void
{
var message:String;
if (e.error["message"])
{
message = e.error["message"];
}
else if (e.error["text"])
{
message = e.error["text"];
}
else
{
message = e.error["toString"]();
}
trace("Uncaught Error: " + e.text);
}
}
}
I had the same issue as above - I was referencing stage.loadInfo, believing that as that references the stage, it would capture all uncaught errors. However, that doesn't work, you have to actually follow grapefukt's suggestion verbatim: On the actual base display object, place the code
loaderInfo.uncaughtErrorEvents.add...
When you try to place onto stage.loaderInfo or frame.loaderInfo, it has no effect.
In my case, I had to place it in the class that extended the base display object. Very Odd.
The docs say that:
The UncaughtErrorEvents object that dispatches the event is associated with either a LoaderInfo object or a Loader object.
Thus you must listen to the loaderInfo's uncaughtErrorEvents property of your topmost display object:
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
UPDATE: I think I may know why you think this isn't working. I made the mistake of testing inside the debugger. When the debugger stopped on the runtime errors I assumed that this proved my uncaughtErrorHandler function was not working. In fact, this was in error. It's just a quirk of the debugger. The debugger will still stop as if it is an unhandled error or exception, but if you press Run again you'll see it DOES execute the error handling code. See my thread Flex 4.0/4.5 global error handling for more info.
Original response:
I am looking for this same info. None of the examples in the API doc nor various blogs on the subject work for me. I've tried just loaderInfo, stage.loaderInfo, systemManager.loaderInfo... It makes no difference. I even tried all of them in a single test case! The addEventListener are being set but the uncaught errors are not firing the uncaughtErrorHandler. Argh. I have wasted far too much time on this! I've reduced it to a very simple program much like above except with all the code in the main mxml file.
How about this: can someone post a Global Error Handling example that DOES work? I'm using Flex SDK 4.1 (I've also tried with 4.5), targeting FP 10.1 (or 10.2 for 4.5), in a mx:Application-based mxml Flex project.
My thread: Flex 4.0/4.5 global error handling
You must set up the listener not to a specific view, but to the main stage object, as it's at the top of the display list (thus picking up any exception of any of its children).