Open lmeurs opened 11 years ago
Ok, the problem got more clear. Sending messages from an external file is possible the way one expects, but not (always) at execution time. Perhaps a loading issue?
The Communication example code sends a ready
message at the final line. When the example code remains in an external file, this message is not (always) received by the DOM, only when you delay the execution of the example code by ie. setTimeout(func, 10);
.
NB: This always worked on my local setup in Chrome and 50% of the times in Firefox.
@lmeurs just to provide a little bit more color, I had a similar issue where the different bonsai events I expected to receive when I could start drawing and sending messages back wasn’t accurate when using plugins.
I have the following in my main bonsai code, and on the document side I wait for this message to be received before sending any messages across.
// emit ready event
stage.once('tick', function () {
stage.sendMessage('ready', {});
});
The Communication example works great, but as it seems only when the Bonsaijs code is sent as a
code
option when callingbonsai.run()
and not when the code is in an external file, ie.:External file:
NB1: I could not get this to work on jsfiddle, since the external file from our server did not get loaded, probably due to cross domain issues. NB2: The
movie.on('load', function() { ... });
event did get triggered.When I call
bonsai.run()
on an external file (with or without the binding of load and message events):And the external file only contains:
The output in the Chrome console is _Error logging argument: (Error: DataCloneError: DOM Exception 25)_, Firefox outputs something similar.
Is this a bug or am I missing something?