-
Why are Extendscript objects invalidated when created inside functions?
2
function addControl(layer, name){ newCtrl = layer("Effects").addProperty("Slider Control"); newCtrl.name = name; return newCtrl; } var Slider1 = addControl(ExistingLayer, "slider 1"); $.write(Slider1.name); var Slider2 = addControl(ExistingLayer, "slider 2"); $.write(Slider1.name);Error Code# 45: Object is invalid
Attempting to access Slider1.name after Slider2 is created results in an error as Slider1 is now [Invalid Object]
I feel this has something to do with referencing and garbage collection but as javascript objects should pass as reference and 'addProperty' should create a new object, I don't understand why.
I should add it fails with and without the 'var' keyword
Sorry, there were no replies found.