access to SubObject, self ,Parent Child ? how ?

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
Hi, maybe i'm wrong, if some can give me the good ways.
How to access to parent property in a sub property ?
i try this but my property self return me Windows ??


example:


$dataArmors[1].meta.Quest = {
self: this,
Status: false,
SubQ: [{
SelfTest: function (){return self.Status}
}]
}
// After i try call test
$dataArmors[1].meta.Quest.SubQ[0].SelfTest() // Return me undefined ?


Ho i only a example, but how i can acces to parent of the SubQ ??


thanks  a lot
 
Last edited by a moderator:

izyCoder

Villager
Member
Joined
Dec 22, 2014
Messages
26
Reaction score
11
First Language
English
Primarily Uses
can't you just

Code:
$dataArmors[1].meta.Quest.SelfTest()
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
@izyCoder


SelfTest are in SubQ array
 am try to get a value are inside my parent, back the array.


Access parent's parent from javascript object
 
Last edited by a moderator:

izyCoder

Villager
Member
Joined
Dec 22, 2014
Messages
26
Reaction score
11
First Language
English
Primarily Uses
maybe because in SelfTest, the self.status is not defined.

Code:
function (){
return self.Status
} //not defined
Code:
function (){
var self = {Status:"test"};
return self.Status
} //return "test"
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
There's no way to access a parent property.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
I think I may have expressed myself badly.


How to get the status in my function here ?

Code:
myparent = {
	status: false,
	Sub: {
		subA: function () {return this.status}
	}
}
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
The only way to achieve that would be this:

Code:
var myparent = {};
myparent.status = false;
myparent.Sub = {
  subA : function() {
    return this.status;
  }.bind(myparent)
};
 
Last edited by a moderator:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
@Hudell


i read  The bind() method was deprecated in version 3.0. Use the on() method instead.


i can do similar with this method ?
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
No. That's about jquery.


The javascript bind is not deprecated.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top