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

Checkbox Value

$
0
0

Hello ,i am trying to ,with one button and a checkbox to switch between two functions.

But when i check the value of this checkbox ,at the first use,it works ,but then, when i change it,

it's always the value i use at the begining .

 

So i dont know how to verify after each click the new value of my checkbox ??

 

Here is my code ,if somebody has an idea..

 

Thank you everyone

 

 

 

function FILL(obj)

 

 

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

    //================= UI============================

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

   

  {

       

    function addHGroup(conteneur){

  var groupe = conteneur.add("group");

  groupe.alignChildren = ["fill","fill"];

  groupe.orientation = "row";

  groupe.spacing = 1;

  groupe.margins = 0;

  return groupe;

    }

    function addVGroup(conteneur){

        var groupe = conteneur.add("group");

        groupe.alignChildren = ["fill","fill"];

        groupe.orientation = "column";

        groupe.spacing = 1;

        groupe.margins = 0;

        return groupe;

    }

            

    var fenetre = obj instanceof Panel ? obj : new Window("window","BS_TOOLS",undefined,{resizeable:true});

    fenetre.alignChildren = ["fill", "top"];

    fenetre.spacing  = 2;

    fenetre.margins = 2;

   

 

 

   

    var fillGroup01 = addHGroup(fenetre);

    fillGroup01.alignment = ["fill","top"];

    var FillButton01 = fillGroup01.add("button",undefined,"FILL"); 

 

   

    var fillGroup02 = addHGroup(fenetre);

    fillGroup02.alignChildren = ["fill","center"];

    var CheckButton = fillGroup02.add("checkbox",undefined,"Other Color?");

    CheckButton.size = [100,25];

  

   

   

//CLICK_______________________________________________________________________________

 

 

 

 

 

 

FillButton01.onClick=function Choix() {if (CheckButton.value==false) {FillButton01.onClick=MyFunction01}else{FillButton01.onClick=MyFunction02}};

 

 

 

 

 

 

 

 

 

 

 

 

//FUNCTIONS ____________________________________________________________________

  

   

   

    function MyFunction01()

{

// create an undo group

app.beginUndoGroup("AddEffect");

 

 

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;

 

 

 

 

// check if comp is selected

if (curItem == null || !(curItem instanceof CompItem)){

 

 

// if no comp selected, display an alert

alert("Please establish a comp as the active item and run the script again");

 

 

} else {

 

 

// define the layer in the loop we're currently looking at

var curLayer = curItem.selectedLayers[0];

 

 

// check if that layer is a footage layer

if (curLayer.matchName == "ADBE AV Layer"){

 

 

// add a FILL COLOR

var myEffect = curLayer.Effects.addProperty("ADBE Fill");

myEffect.color.setValue([0.33529413938522,0.87653977274895,0.47653977274895,1]);

 

 

}

}

 

 

// close the undo group

app.endUndoGroup();

}

 

 

 

 

 

 

function MyFunction02()

{

// create an undo group

app.beginUndoGroup("AddEffect");

 

 

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;

 

 

 

 

// check if comp is selected

if (curItem == null || !(curItem instanceof CompItem)){

 

 

// if no comp selected, display an alert

alert("Please establish a comp as the active item and run the script again");

 

 

} else {

 

 

// define the layer in the loop we're currently looking at

var curLayer = curItem.selectedLayers[0];

 

 

// check if that layer is a footage layer

if (curLayer.matchName == "ADBE AV Layer"){

 

 

// add a FILL COLOR

var myEffect = curLayer.Effects.addProperty("ADBE Fill");

myEffect.color.setValue([0.63529413938522,0.27653977274895,0.27653977274895,1]);

 

 

}

}

 

 

// close the undo group

app.endUndoGroup();

}

 

 

 

 

 

 

//================= SHOW UI============

    fenetre.layout.layout(true);

    fenetre.layout.resize();

    fenetre.onResizing = fenetre.onResize = function () {fenetre.layout.resize()};

    if (fenetre != null ) if (fenetre instanceof Window) fenetre.show();

    }

 

 

 

 

 

 

FILL(this);


Viewing all articles
Browse latest Browse all 2143

Trending Articles



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