So...where do you create global variables?

where do you create global variables ?
That can be accessed by all the different types of functions in Saola ?

Hi Bracer,

Each event handler function has a doc parameter that you can attach your variables and access them in any other handler. For example:

function handler1(doc, e) {
  // init variable
  doc.myVariable = 'test';
function handler2(doc, e) {
  // get variable

For normal function (that is not an event handler), you need to add doc parameter manually.


So doc is a global object !
Nice !
Please put it in the documentary, this single useful information makes everything clear and also easier now !

Let me explain why this makes everything easier, initially I was going to ask how do I retrieve the x and y position of another element on the screen(please answer that if it is easy to answer ;p), but now knowing this information, I will just simply make it a point to keep a reference of each object inside doc itself, it is tedious because I am sure an existence scene graph already exist though I have no idea how to access it via scripting but at least knowing that doc can be accessed everywhere makes me understand that at least I can do it manually and everything is possible now, thanks.

You can access the DOM properties of any other element by using:

var styleObj = doc.getElement("D1")
console.log( + "," + styleObj.left);

Hello mackavi, you are quickly becoming a helpful and recognized helper here ! Thank you !
I have no access to Saola at the moment, are you sure it’s not getElementById or get ElementByName ?
Thanks !

Quite sure - it’s a method of the ‘doc’ object. The other two are pure JS functions for accessing the dom directly.

You Sir, are just such a wonderful addition to the learning experience here :smiley: