Forums > Javascript

multiple js objects sharing information


May 25, 2013 | 7:57 am

Read  the Max tutorials about java and the global object, but cannot find out, how  js objects share Infomations. Woulf like to create an array in one js object and share it with another js object.

Thanks for any help!

 


Nat
May 25, 2013 | 8:18 am

The Global object should allow you to do this, otherwise the new Dict object should work too.

May 25, 2013 | 9:06 am

Found the solution for me:

first js pbject:

glob = new Global("bounce");

glob.a_array = new Array;

creating array b_array in second js object, then:

glob = new Global("bounce");

glob.a_array=b_array;

 

May 18, 2015 | 3:28 pm

I’ve a probleme with the Global Object.

I do not have any probleme with the last message in that thread, I mean , I’m able to create a Global array and access it from an another instance of JS.

My probleme is that I’ve created a data structure that contain array, variable type etc… but that was before figure out that it could be useful for me to make it Global.

So, as I understand it for the moment (maybe I’m wrong) I will need to change all my code for make it Global ? ok lets say I’ve this :

var ridge = function () {
this.area = null;
this.delt = [];
this.ecar = null;
this.len = null;
this.max = null;
this.signe = null;
this.vari = null;
}
var delta = function () {
this.signe = null;
this.pos = null;
this.len = null;
}
var all_ridge = [];

function bang()
{
for (i ; i < 10; i ++) {
all_ridge[i] = new ridge();
for(j; j < 10 ; j++) {
all_ridge[i].delt[j] = new delta();
}
}
}

How Can I make that all_ridge data structure Global ? I will need to change all my code using ‘glob.all_ridge[i]’ ?

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > Javascript