I use object literal for my js, and below you can see it's "global" variables. One of them is an object (theBody) which in turn contains of an array called 'bodies'. This array contains of several objects (just one in the example below), which are svg objects.
I want to be able to assign the fill value from a specific variable, called bodyColor but when I change:
'fill':'#e59225',
to
'fill': AvGen.theBody.bodyColor,
I get the error Uncaught ReferenceError: theBody is not defined
Why is that and how can I access bodyColor for the object property?
from the js:
var AvGen = {
paper: null,
theBody: {
bodies: [
[0,0,277.9,308.5,{
type:'path',
'fill':'#e59225',
'stroke':'none',
'stroke-width':'0',
'fill-opacity':'1',
'stroke-opacity':'0'
}],
],
currNr: 1,
currObj: null,
bodyColor: '#e59225'
},
init: function() {
}
}
AvGenis defined or not, just do a console.log to test it, as error clearly specifiesUncaught ReferenceError: AvGen is not definedAvGenis defined after you attempt to use it, or it's defined in a closure and your code referencing it isn't in scope.