Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Why are Extendscript objects invalidated when created inside functions?

  • Why are Extendscript objects invalidated when created inside functions?

    Posted by Carey Pagan on March 16, 2021 at 10:02 pm

    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

    Carey Pagan replied 5 years, 2 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy