try statement tripping debugger (as3) - actionscript-3

Trying a try-catch sequence that works fine in release version, but running it in debugger causes errors to be displayed. Obviously there errors, that's why I'm using this stuff inside try, but I'm wondering if there's any way I can get debugger to stop stopping. While I don't even mind the error message, the app no longer executes properly.
I've got a this[$val] that I needs to return a null if there is no such variable inside the class.
try {
return this[$val]+"";
} catch(error:ArgumentError) {
// Do nothing
}
return "";
again, this works like it is supposed to, but it causes errors in debugger
any ideas for an alternative?

I think you are catchin an argument error in place of the real problem of handling a null object + string error.Try Using;:
try {
return this[$val]+"";
} catch(error:Error) {
// Do nothing
}
return "";

Related

Rescheduling same method in Cocos2d-x 3.1

I have the following code in Cocos2d-x v3.1:
void Board::createNewRandomBottomRow()
{
//eventHappening is a variable modified in other parts of the code
//I don't want that while eventHappening is true, this method does anything
if ( eventHappening ) {
this -> scheduleOnce( SEL_SCHEDULE( &Board::createNewRandomBottomRow ), 0.3f );
}
else
{
//actual logic
}
}
However, I check with the debugger that the method is not being rescheduled. Isn't it possible to reschedule a method from inside the same method?
Well, I did the same again in another simpler scenario, and the rescheduling works fine, so I guess I messed up in the logic in another part of the code.
So just to sum up: rescheduling a method from inside the method itself works fine.

Cannot find method moneyToMicros((class))

I'm trying to programmatically change the max cpc with an AdWords script, but I'm getting an error. The console just says "Cannot find method moneyToMicros((class))". I cannot find any documentation about this error or any other posts about this anywhere. Was wondering if anyone knew how to get around this. Here's a small snippet of the code where the error occurs (error occurs on the line where setKeywordMaxCpc() is called):
while (adGroupIterator.hasNext())
{
var adGroup = adGroupIterator.next();
var adGroupName = adGroup.getName();
if (adGroupRegex.test(adGroupName))
{
if (adGroup.isPaused())
{
adGroup.enable();
adGroup.setKeywordMaxCpc(bidModifier);
}
}
else
{
adGroup.pause();
}
}
I had the same problem and I've just resolved it!
I was passing the value "null" to the function .setKeywordMaxCpc();
So I think you need to check if the variable bidModifier is null before you execute the function .setKeywordMaxCpc(bidModifier );
In my case I was using the value keyword.getFirstPageCpc() to set my bid, and in some words that value is null.

Windows Phone speech recognition - words that are not in grammar

consider a grammar like this ; speech.Recognizer.Grammars.AddGrammarFromList("answer",new string[] { "Go.","no" });
When I say something else that are not in grammar, she says "sorry didnt catch" and then tries to start it again. Same goes for null input.
What I want is that it should only recognize the words in grammar and for everything else it should just pass the recognition. I don't want to see anything like "sorry didnt catch" and second time recognotion. Any idea ? thanks.
Edit : with try-catch I can avoid from second time recognotion if the word is unknown but now it's waiting too long on "sorry didnt catch" part.
try
{
SpeechRecognizerUI speech = new SpeechRecognizerUI();
speech.Settings.ReadoutEnabled = false;
speech.Settings.ShowConfirmation = false;
speech.Recognizer.Settings.InitialSilenceTimeout = System.TimeSpan.FromSeconds(0.8);
speech.Recognizer.Grammars.AddGrammarFromList("answer", new string[] { "Go.", "no" });
SpeechRecognitionUIResult result = await speech.RecognizeWithUIAsync();
if (result.RecognitionResult.Text == "Go.") { .... }
}
catch
{
..... }
In my opinion, you must build your own UI to avoid this. So you should use SpeechRecognizer and then you can handle the input as you want.
In my case I even created two SpeechRecognizer, on with own Wordlist, the other one with default dictionary. It works like a charm, but I couldn't get it to work with SpeechRecognizerUI.

NPAPI Plugin[FireFox]: Invoke() / HasProperty() / HasMethod() not getting called

I am developing NPAPI Plugin for Firefox on windows. here is the my java script:
document.addEventListener('load', documentLoad, true);
function loadPlugin(doc)
{
var objWebMon = doc.getElementById("my_firefox");
if(!objWebMon)
{
var objWebMonEmbed = doc.createElement('embed');
objWebMonEmbed.setAttribute('id', 'my_firefox');
objWebMonEmbed.setAttribute('type', 'application/npplugin');
objWebMonEmbed.setAttribute('style', 'height: 10px; width:10px; display:block;');
if(doc.body)
{
doc.body.insertBefore(objWebMonEmbed, doc.body.firstChild);
}
}
}
function documentLoad(event) {
try
{
var doc = event.originalTarget; // doc is document that triggered "onload" event
loadPlugin(doc);
var myplugin = doc.getElementById('my_firefox');
if(myplugin)
{
myplugin();
myplugin.myAction();
}
} catch(err)
{
}
}
as I am calling myplugin()
bool ScriptablePluginObject::InvokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result)
gets called sucessfully but on calling function myplugin.myAction()
bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result)
function doesn't called. I have declared myAction inside ScriptablePluginObject::HasProperty(NPIdentifier name) even HasProperty method is not getting called.
Inside catch block i am getting this error. TypeError: fasso.myAction is not a function.
Here are a couple of things to try:
Use an object tag instead of an embed -- I've had more consistent success with object tags, despite the wide popularity of using embed
Never ever ever set the type of an object or embed tag before you add it to the DOM -- doing so causes it to instantiate the plugin and then puts it in a kinda weird state when it gets moved. I don't think this is causing your issue this time, but it's worth trying.
You may need a slight delay between inserting hte plugin into the DOM and using it. Try adding a setTimeout with a delay of 50ms and accessing the plugin in the callback function.
Honestly, #3 is the one I think most likely will make a difference, but I present the other two as they have bitten me on weird things in the past. Good luck!

multiple tinyMce instances not working in chrome

As with the title in Chrome (v.4.1) multiple tinyMce (v2.08) instances do not work. To be exact the first two instances are ok, the others not, and chrome gives this error:
Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
Has this happened before?
Unfortunately I can't show you any code because it's for an admin area, I just need some clue for the moment.
Yes, as user XP1 noted, at this link you can find resolution for a comprimed TinyMCE source:
http://my.opera.com/XP1/blog/2011/07/21/tinymce-javascript-error-in-opera-getrangeat-index-size-err
But if you want to work with original uncomprimed source (it's just a bit easier), here is the solution:
Look for code "setRng : function(r) {" (without quotes) and exchange the whole function with:
setRng : function(r) {
var s, t = this;
if (!t.tridentSel) {
s = t.getSel();
if (s) // this block fixed according to TinyMCE JavaScript error in Opera (getRangeAt, INDEX_SIZE_ERR); http://my.opera.com/XP1/blog/2011/07/21/tinymce-javascript-error-in-opera-getrangeat-index-size-err
{
if(s.anchorNode === null && s.focusNode === null)
{
t.explicitRange = r;
try {
s.removeAllRanges();
} catch (ex) {
// IE9 might throw errors here don't know why (NOW WE KNOW WHY DAMMIT!)
}
s.addRange(r);
}
if (s.rangeCount > 0)
t.selectedRange = s.getRangeAt(0);
}
} else {
// Is W3C Range
if (r.cloneRange) {
t.tridentSel.addRange(r);
return;
}
// Is IE specific range
try {
r.select();
} catch (ex) {
// Needed for some odd IE bug #1843306
}
}
},
ONE NOTE: please make sure variables match. I am not sure how it is between different TinyMCE versions BUT the variables are not the same between comprimed and src mutations of the script file.
Take Care and God Speed