TypeError: $it0.hasNext is not a function - compatibility

Running a few canvases which work fine in chrome but fail in the latest version of Mozilla. I know this was an issue a while back and I thought the new processing-1.4.1.js was fixed to accommodate for the for loop failure seen here. Does anyone know if they did or if not, why this is happening and how to fix it?
edit:
Test code that will not work:
void setup() {
String names[] = {"Alexis", "Thomas", "Antoine"};
for(String name : names) {
alert(name); // doesn't on Firefox 17+, bug?
}
}
void draw() {
}

This is a problem with Processing.js and some recent changes in Firefox as discussed here.
You have two options:
Solution 1 is to hack Processing.js file as discussed by alexbbrown in the aforementioned link (a harsh and nasty solution), essentially finding the actual Processing.js file, editing it with your favourite text editor and change lines 291-292 from:
if (obj.iterator instanceof
Function) return obj.iterator();
to:
if (obj.iterator instanceof Function && obj.hasNext instanceof Function)
return obj.iterator();
Solution 2 is to change your code and live without the lovely for-each syntax (a softer, compromising solution), replacing the lines:
for (String name : names) {
alert(name); // doesn't on Firefox 17+, bug?
}
with the common for syntax:
for (int i = 0; i < names.length; i++) {
alert(names[i]);
}
whatever you do, may the for be with you...

Related

Wrong fields reset when method SalesLine.modifiedField is called from code

Take any sales order with a line that has fields SalesLine.Name and SalesLine.ExternalItemId populated.
Then run following job trying to modify any field not related to the two above:
SalesLine sl = SalesLine::findInventTransId('US01-000025', true);
ttsBegin;
sl.CustomerLineNum = 100; //any other field will serve as well
sl.modifiedField(fieldNum(SalesLine, CustomerLineNum)); //causes the issue
sl.update();
ttsCommit;
When the job has completed, both Name and ExternalItemId will be reset.
The issue is caused by line this.axInventDim().isFieldSet(fieldNum(InventDim, ConfigId)) in \Classes\AxSalesLine\isCustExternalItemDescriptionFieldsSet, which always returns true.
As a result, methods AxSalesLine.setName and AxSalesLine.setExternalItemId populate respective fields with default values.
Any advice on the reason it has been coded in Microsoft this way, and the best way to fix this?
P.S. I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId that was introduced in R2 CU7
This is a base bug that was resolved 4/30/15 on KB3061573.
https://fix.lcs.dynamics.com/Issue/Resolved?kb=3061573&bugId=3612128&qc=83c15cd8881ece605195acc30e039142
I think the full method fix is close to what you have, but the hotfix may also adjust other methods. I hope this hotfix is satisfying knowing you're not crazy.
protected void setRetailVariantId()
{
InventDimCombination comb;
InventDim inventDim;
;
comb = InventDimCombination::findVariantId(salesLine.RetailVariantId);
inventDim = this.axInventDim().inventDim();
if(comb)
{
if (inventDim.InventSizeId != comb.inventDim().InventSizeId)
{
this.axInventDim().parmInventSizeId(comb.inventDim().InventSizeId);
}
if (inventDim.InventColorId != comb.inventDim().InventColorId)
{
this.axInventDim().parmInventColorId(comb.inventDim().InventColorId);
}
if (inventDim.InventStyleId != comb.inventDim().InventStyleId)
{
this.axInventDim().parmInventStyleId(comb.inventDim().InventStyleId);
}
if (inventDim.configId != comb.inventDim().configId)
{
this.axInventDim().parmConfigId(comb.inventDim().configId);
}
}
}
// </RETAIL>
As I mentioned in the postscript, I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId, which was introduced in R2 CU7.
As a workaround, I have added one line to the code, it resolved the issue:
if (this.axInventDim().parmConfigId() != comb.inventDim().configId) // added check
this.axInventDim().parmConfigId(comb.inventDim().configId);
I'll wait some time for a better answer/fix. If none provided, I will accept this answer.

Handlebars.js: how does partials gets invoked in a helper? I got: TypeError: fn is not a function

I am learning Handlebars. It still appears to be a mystery to me that how a partials gets invoked in a helper.
I read this tutorial: http://blog.teamtreehouse.com/handlebars-js-part-2-partials-and-helpers
From this example in the tutorial,
Handlebars.registerHelper("stripes", function(array, even, odd, fn) {
var buffer = "";
for (var i = 0, j = array.length; i < j; i++) {
var item = array[i];
// we'll just put the appropriate stripe class name onto the item for now
item.stripeClass = (i % 2 == 0 ? even : odd);
// show the inside of the block
buffer += fn(item); <!-- this is where a partials gets invoked -->
}
// return the finished buffer
return buffer;
});
it appears the partial is added and applied by Handlebars. However, I used this same approach in Handablebars 1.3.0 and 2.0 Alpha-2, it seems no longer the case. I always got the error:
TypeError: fn is not a function
buffer += fn(item);
I did quite online search and found a number tutorials, but none of them shows how partials is hooked up with a helper in version 1.3.0 or later.
Can someone help me out?
Thanks a lot!
OK. I believed I solved this problem. In v1.0 or later, Handlebars puts everything in a hash, not just fn. So, everything in the above post still is valid except these two lines:
Handlebars.registerHelper("stripes", function(array, even, odd, options)
...
buffer += options.fn(item);
Hope this helps someone else. Any confirmation is welcome. I feel bad that there is no direct example on this, at least I did not find it.
Regards.

InDesign SDK : Drag'n'Drop from a Flex Panel

I have a Flex panel, in InDesign, from which I drag an URL. If I drop this URL on a text editor or a web browser, it works. But when I try to drop it on my InDesign document, it's a little bit harder.
I have implemented a subclass of CDragDropTargetFlavorHelper. The drop works perfectly on Windows. But on mac, I have problems in the method CouldAcceptTypes :
DragDrop::TargetResponse AutocatDNDCustomFlavorHelper::CouldAcceptTypes(const DragDropTarget* target, DataObjectIterator* dataIter, const IDragDropSource* fromSource, const IDragDropController* controller) const
{
if (0 != dataIter && 0 != target)
{
DataExchangeResponse response = dataIter->FlavorExistsWithPriorityInAllObjects(kURLDExternalFlavor);
if (response.CanDo())
{
...
}
}
}
The problem is that response.canDo() answers kTrue on Windows, but kFalse on Mac. I tried to explore the content of dataIter, but a call on dataIter->First() returns nil. I tried a controller->GetItemCount(), which returns 1. But if I try a controller->GetDragItem(1), I get a nil pointer. I have the impress there is no item. Though, the drop works on another app than InDesign, as I said.
Is it a problem of internalization ? Or something else ? It let me dry.
Thanks in advance
-------------------------- EDIT -----------------------------------
I solved this problem, but discovered another one. The flavor sent by the flex panel has been changed, so that it's a text flavor instead of an URL flavor. My method couldAcceptType works now :
DragDrop::TargetResponse AutocatDNDCustomFlavorHelper::CouldAcceptTypes(const DragDropTarget* target, DataObjectIterator* dataIter, const IDragDropSource* fromSource, const IDragDropController* controller) const
{
if (0 != dataIter && 0 != target)
{
// Check for URL Flavor in the drag
DataExchangeResponse response = dataIter->FlavorExistsWithPriorityInAllObjects(kTEXTExternalFlavor);
if (response.CanDo())
{
return DragDrop::TargetResponse(response, DragDrop::kDropWillCopy);
}
}
return DragDrop::kWontAcceptTargetResponse;
}
The problem is now in the ProcessDragDropCommand method. Here is the code :
ErrorCode AutocatDNDCustomFlavorHelper::ProcessDragDropCommand(IDragDropTarget* target, IDragDropController* controller, DragDrop::eCommandType action)
{
// retrieve drop data
IPMDataObject* dragDataObject = controller->GetDragItem(1);
uint32 dataSize = dragDataObject->GetSizeOfFlavorData(kTEXTExternalFlavor) ;
...
}
The problem is the IMPDataObject I get is nil. There is no item in the controller. However, there were items in the CouldAcceptTypes method, in the DataObjectIterator. So, where are my items ?
I tried using a custom CDataExchangeHandlerFor, but could not really understand what its usage was for. It didn't work anyway.
Has anyone an idea ?
Regards,
RĂ©mi
The problem is the argument of the GetDragItem. It is 1 on PC. It is a strange value on Mac (something like 719853). The only dirty solution I found is doing a memcpy from the object retrieved drom the dataIter in the CouldAcceptTypes method, and use it in the ProcessDragDropCommand method.

Getting characters position in TLF

i am trying to figure out if i can in anny way get the exact position for every character inside a textflow?, also I'm having trouble with the TLF documentation, is there anny documentation that shows more on how to work with it in actionscript rather than mxml, im looking to write my own component and perhaps not use richtexteditor if i don't need to.
Many thanks!
Edit: i finally think i figured out how to get each characters position in the textflow:
private function getCharPosition():void {
for (var i:int=0; i<=textController.flowComposer.numLines; i++) {
var textFlowLine:TextFlowLine = textController.flowComposer.findLineAtPosition(i);
var textLine:TextLine = textFlowLine.getTextLine();
trace('number of atoms in this line: ' + textline.atomCount);
for (var j:int=0; j<=textLine.atomCount; j++) {
try {
trace(textLine.getAtomBounds(j));
} catch (e:Error) {
trace('error');
}
}
}
}
This returns an error that's why i have try and cache, i have tried to change textLine.atomCount to -1 but that wont work either. Now i don't know what character exactly that i have the position for. Lots of figuring out yet...
You can use some of these steps which (among other things) allow to determine character's bounds.
What about your second question you can refer to the following documentation and/or some samples.

Flex 3 : Easy Deep Linking Question

I'm having a problem with deeplinking on my Flex 3 site. I want people to be able to link to different parts of the site. I also want to be able to type a url into the browser bar and be taken to a particular part of my site. Also, I need the default to open to #view=2.
I'm having problems setting the default #view=2. So, it's supposed to check the browser fragment to see whether its a valid section of the site. If it is then it should call parseUrl() and open that section of the site. So far, so good. The problem is how do I set the default to view=#2, if the loop doesn't find a valid view number?
Here's my code:
private function initBrowserManager(): void {
browserManager = BrowserManager.getInstance();
browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseUrl);
browserManager.init("","My Website");
if(browserManager.fragment != null){
for (var j:uint = 0; j < ComboBoxDP.length; j++){
if(browserManager.fragment == "view="+ComboBoxDP[j].series){
parseUrl();
break;
}
}
}
}
I've tried to add this line: else{browserManager.setFragment("view="+ 2); parseUrl();} everywhere I could think of, but no luck so far. I know that the answer will be really simple. Any suggestions?
Thank you.
-Laxmidi
I'm assuming some of the intent of the code, but I'd use a boolean:
var initialFragmentValid:Boolean = false;
if(browserManager.fragment != null){
for (var j:uint = 0; j < ComboBoxDP.length; j++){
if(browserManager.fragment == "view="+ComboBoxDP[j].series){
initialFragmentValid = true;
break;
}
}
}
if (!initialFragmentValid) {
// set the default
browserManager.setFragment("view=2");
}
// always parse initially because we'll have a fragment regardless
parseUrl();

Resources