We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

External Call fails for me

Home Forums Bug Reports and Feature Requests External Call fails for me

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #455
    lukevideo
    Participant

    i get a error message when i try to use the external call app. It fails in firefox and chromium.

    player.html:1 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().
    Promise (async)		
    Blockly.WorkspaceAudio.preload	@	puzzles.min.js:1
    i	@	puzzles.min.js:1
    s	@	puzzles.min.js:1
    VM129:129 Uncaught TypeError: v3dApp.ExternalInterface.myJSFunction is not a function
        at eval (eval at evalBlocklyCode (puzzles.min.js:1), <anonymous>:129:28)
        at eval (eval at evalBlocklyCode (puzzles.min.js:1), <anonymous>:101:13)
        at HTMLCanvasElement.onMouseDown (eval at evalBlocklyCode (puzzles.min.js:1), <anonymous>:85:12)
    (anonymous)	@	VM129:129
    (anonymous)	@	VM129:101
    onMouseDown	@	VM129:85
    
    #456
    lukevideo
    Participant

    Maybe it’s just a demo of the call but if it console.log something it might be nicer… :wacko:

    #457

    Hi Luke,

    You should define your external function first, for example:

    v3dApp.ExternalInterface.myJSFunction = function(a, b, c) {console.log(a, b, c)};

    Just paste this in console for quick test.
    P.S. Will make explanations for that example app.

    Chief 3D Verger | LinkedIn | Twitter

    #707
    Will Welker
    Customer

    Still getting an uncaught error in the ‘External Call” example.
    Uncaught
    It seems like if I was adding my own functions to call, it should be in External_Call.js, but there is no such file.

    #710
    Will Welker
    Customer

    I should add, it happens when clicking the plane.

    #711

    Hi Will,

    This example seems to be over-minimalistic :) You can quickly make it work by pasting to the browser console something like

    v3dApp.ExternalInterface.myJSFunction = function(a, b, c) {console.log(a, b, c)};

    After that this function becomes ‘registered’ in the ExternalInterface namespace and available to Puzzles.

    But of course, application developers should implement external functions in their code, so that they become persistent. To do this, create a ‘Custom’ application with App Manager and add that line of code in the main JS file (where the comment ‘add you code here’ is found). This way your app’s JS code will communicate with Puzzles and vice versa. :)

    Chief 3D Verger | LinkedIn | Twitter

    #716
    Will Welker
    Customer

    Ok, I got it figured out. I think what is confusing about this, is that for an example, the expectation is that it is all complete and working.
    Here is an idea to dumb it down a little:
    Add three buttons, one for each box, label each on “Call external function.”
    When clicked these will call MyJSFunction() from an existing JS file and do a console log: “Called MyJSFunction from External_Call.js.
    In this external function, place a call back to the Puzzles “When called from JS” block.
    Maybe with a comment in the JS file: //This function calls the Puzzles block OpenCover.
    Then, console.log(“Call from MyJSFunction to open the” + which_box + “box”);

    Or something like that :unsure: LOL
    Anyway, it would go full circle from Puzzles to custom JS and back to Puzzles with full comments and console logs to explain what is happening.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.