Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Using Singleton Pattern to Retain Previous Variable Values?

$
0
0

Is it possible using ExtendScript to retain the previous value of a property even after it has been updated by the user? I know after effects expressions update every frame, but I believe script values should be able to to persist. Is this sort of thing possible with ExtendScript?

 

I'm thinking something like this should be do-able using a singleton like pattern, but so far I have been unsuccessful. Heres what I've tried so far:

 

    var instance;

   

    //Check current instance value

    alert(getInstance().value);

   

    //Check if instance has a value, if not assign one, otherwise return current value

    function getInstance(){

        if(!instance){

            instance = createInstance();

        }

        return instance;

    }//End getInstance

   

   //Create new object with a value and return it

   function createInstance() {

        var object = new Object(mySel.property("Effects").property("Transform").property(1));

        return object;

    }//End createInstance

 

Or, if singletons are the wrong approach is there any type of storage mechanism that can be called in ExtendScript to write values to?

 

Thanks!


Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>