LiveAPI callback issues and questions regarding M4L-device-specific callbacks
When I create a LiveAPI callback (call it "CB") in a Max For Live device (call it "D") and set CB's property to D's canonical parent name, it works fine on the first instantiation of D. But, if I instantiate, say, 8 Ds, then only the 8th D receives callbacks. What I think is happening is callback functions are not unique in Live, and each time I add a new instance of D, it updates Live, and the sole CB function in Live now is connected to the 8th D.
I did a lot of research and experiments to try to assign a unique, M4L-device-specific callback function name in JavaScript, but nothing worked. For example, I created a dynamic JavaScript function with a M4L-device-specific function name, but I ran into a scoping issue; that is, the dynamic function was working and correctly assigned to the LiveAPI object, but it could not access any variables or functions outside of itself, which made it useless.
Questions:
1. Am I doing something wrong?
2. Is there a way to have unique callback functions?
Many thanks for your time.
1) Very likely. Are you scoping your LiveAPI object correctly?
2) Unique to what scope? This would make a callback unique to the js file it is used in, and that references functions outside of itself.
var api = null;
function bang() {
api = new LiveAPI( CB, <idwhatever> )
}
function CB() {
// stuff
otherstuff()
}
function otherstuff() {
}
Hi Tyler,
Thank you for the reply. I am grateful for the help.
After some more testing, I figured out the problem. To aid in some previous testing, I was sending a compile to my js device immediately after loading. I guess that was mucking up my callbacks somehow. Removing the compile solved the problem.
In summary, it does, indeed, seem like LiveAPI callbacks are unique/specific to each device instance.
Thanks again.