hecht-software / box2dweb

Automatically exported from code.google.com/p/box2dweb
308 stars 94 forks source link

Box2d and Processing.js don't mix #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Including Box2D and Processing on the same page will break it.

Firefox console outputs:
18:12:22.618: Exception: missing ( before formal parameters Source File: 
file:///C:/b2d/processing.js Line: 17949, Column: 16 Category: content 
javascript

Tested on Windows 7 with Opera 11beta1 and Firefox 4.0b8pre

Original issue reported on code.google.com by kristjan...@gmail.com on 23 Nov 2010 at 4:32

Attachments:

GoogleCodeExporter commented 8 years ago
Here is why:
Box2dWeb defines valueOf() in Object.prototype which provides an unique id for 
each object. This allows using objects as keys and simulates 
flash.utils.Dictionary-behavior:

var d = new flash.utils.Dictionary;
d[{foo: bar}] = "foobar";

Processing.js defines toString at some places in the processing-code -to- 
Javascript compiler. Unfortunately valueOf seems to have higher precedence.

So maybe I can fix it, by making valueOf return the toString() value, if 
available as a workaround.

I'm currently working on version 2.0 of my converter. I hope I can remove the 
valueOf-override at all by improving type-tracking.

Original comment by Uli.He...@googlemail.com on 23 Nov 2010 at 6:43

GoogleCodeExporter commented 8 years ago

Original comment by Uli.He...@googlemail.com on 23 Nov 2010 at 11:00

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r11.

Original comment by Uli.He...@googlemail.com on 24 Nov 2010 at 1:08