Passing a jsobject from one js instance to another. Different behaviour in Max6

    Feb 24 2012 | 5:52 pm
    I've searched the forums and can't find a related discussion, so here goes: Basically, I'm passing some information in he form of a simple jsobject from one js instance to another.
    Sender: (send_obj.js)
    outlets = 1;
    function bang() {
    	var out_obj = {'name':'Jimmy', 'job':'Driver'};
    	outlet(0, out_obj);
    Receiver: (recv_obj.js)
    outlets = 1;
    function receive(in_obj) {
        keys = [];
        for (var key in in_obj) {
    In Max5, it works without a problem, whereas in Max6 when I try to inspect the object in the receiver instance, I always get 'undefined'.
    Furthermore, In Max5, when I list the keys, I get 'name' and 'job' as expected, whereas in Max6 I get 0 1 2 3 4 5 6 7 and if I look at the values, it spells out 'jsobject'. So it appears that it's only getting a string containing 'jsobject' rather than an actual object?
    I'm possibly going to look for another way to pass the information, so if anyone has any suggestions I'm all ears.

    • Feb 28 2012 | 2:43 am
      Hi Murzz,
      In max 6 you can use dictionaries to share simple JSON objects across the JS instances. At least as long these Objects don't contain code/functions or object classes.
      I personally like to work with a simple event-listener structure to pass objects/code around JS in Max. Like this i don't need to poll for changes and Objects can be passed directly from [js ] to [js ] without going through inlets and outlets.
      in this thread (at the end) I recently posted an example of the event/listener construction I use.