Copy link to clipboard
Copied
_definitionsArray[_selectedBubble]["mc"])
Hi, I have this code for an array but why are there sets of square brackets? I thought it was smth like:
_definitionsArray[_selectedBubble]) where _selectedBubble would be a number ie: the index therefore giving us the value at that point. OR would it be because it an associative array with two types and the second bracket indicates you want the mc.
It is possibly making use of bracket notation to target an object with an instance name "mc" that is a child of whatever object _definitionsArray[_selectedBubble] is.
_definitionsArray[_selectedBubble] could be an associative array or it could be a normal array... it really depends on what _selectableBubble's value is.
Copy link to clipboard
Copied
It is possibly making use of bracket notation to target an object with an instance name "mc" that is a child of whatever object _definitionsArray[_selectedBubble] is.
_definitionsArray[_selectedBubble] could be an associative array or it could be a normal array... it really depends on what _selectableBubble's value is.
Copy link to clipboard
Copied
I should add that _definitionsArray[_selectedBubble] could also be making use of the bracket notation to target an object, although the use of "Array" in the name causes me to think _definitionsArray is an actual array.
If you aren't familiar with using bracket notation to target objects, what it does for you is allows you to use strings to target objects, which becomes very useful in dynamic applications.
Here is a brief example... suppose you have an object with an instance name "mc", then suppose you have that as a child of another object with an instance name "container". One way you are probably familiar with for targeting the "mc" object would be...
container.mc as in container.mc.x = 200;
using bracket notation you could also use...
container["mc"] or
this["container"].mc or
this["container"]["mc"]
They all target the same "mc" object
Copy link to clipboard
Copied
Thank you very much, really helpful
Copy link to clipboard
Copied
You're welcome