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

ButtonColor,Picker and save prefs

$
0
0

Hello everone,

 

I'm trying to make a button and change his color when i click on it,using a color picker function i found.

its works,when i click,i can choose a color and then my button turn with the new color.

but i want to save the new color in my after effect preferences,to keep the color info.

The idea is ,when i close and restart my script,he will find the new color and load it...this thing is not working for now....

 

Maybe because i load a sting and not a color value ???

If someone has a solution,it will help me..

 

thanks

Tom

Here is my code:

 var EmptyColor=[0.2, 0.2, 0.2];

if (app.settings.haveSetting("ta_Scripts", "ta_Color1")==true) {      var ValColor1 = app.settings.getSetting("ta_Scripts", "ta_Color1"); 
}else{    app.settings.saveSetting("ta_Scripts", "ta_Color1", EmptyColor.toString());      var ValColor1 = app.settings.getSetting("ta_Scripts", "ta_Color1");    }


//~  var ValColor1=[0.2, 0.2, 0.2];

app.preferences.saveToDisk(); 


alert(ValColor1)


    
function ta_Button(obj)


 //===============================================
    //================= UI============================    //===============================================    
{            function addHGroup(conteneur){
var group = conteneur.add("group");
group.alignChildren = ["fill","fill"];
group.orientation = "row";
group.spacing = 1;
group.margins = 0;
return group;    }    function addVGroup(conteneur){        var group = conteneur.add("group");        group.alignChildren = ["fill","fill"];        group.orientation = "column";        group.spacing = 1;        group.margins = 0;        return group;    }    var window = obj instanceof Panel ? obj : new Window("window","ta_Button",undefined,{resizeable:true});    window.alignChildren = ["fill", "top"];    window.spacing  = 1;    window.margins = 2;    
//BUTTONS///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//SaveAep Button multiples
    var PaletteGroup = addHGroup(window);    PaletteGroup.alignment = ["fill","bottom"];    var PaletteTitle= PaletteGroup.add("statictext",undefined,"Title");        var ColorLine1Group = addHGroup(window);    ColorLine1Group.alignChildren = ["center","center"];        var Color1_Button = ColorLine1Group.add("button",undefined,"",);    Color1_Button.preferredSize=[25,25];        butColor(Color1_Button,ValColor1);//color my Button           


//CLICK///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Color1_Button.onClick = function (){
    var resultColor1 = colorPicker();    app.settings.saveSetting("ta_Scripts", "ta_Color1",resultColor1.toString());    app.preferences.saveToDisk();     butColor(Color1_Button,resultColor1);            //alert(app.settings.getSetting("ta_Scripts", "ta_Color1"))          
}




//================= SHOW UI ============
    window.layout.layout(true);    window.layout.resize();    window.onResizing = window.onResize = function () {window.layout.resize()};    if (window != null ) if (window instanceof Window) window.show();    }




ta_Button(this);










//FONCTIONS///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function butColor(object,color){
if(String(color)!="undefined"&&String(color)!="NaN")  if(color[0]>0)  {      object.onDraw = fillRect;       object.fillBrush= object.graphics.newBrush( object.graphics.BrushType.SOLID_COLOR, color );      object.visible=0;object.visible=1;   }
//===================================================================================================================================


function fillRect(){ 
 with( this ) {
try{          graphics.drawOSControl();        graphics.rectPath(0,0,size[0]-2,size[1]-2);        graphics.fillPath(fillBrush);        }catch(err){}        }}   }




//===================================================================================================================================

Viewing all articles
Browse latest Browse all 2143

Trending Articles



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