Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
Line with "replace" not working if i write it to function

please help me, whi replace not work. Thanks. If i write line with replace out from function it is work, but inside function not work... i dont know why, because alerts work well.... It is a script for replace footage by our choice from dropdown menu.

//show window
var mainWindow = new Window("palette", "", undefined);
mainWindow.orientation = "column";

var iconName = ["Bourky_s_destem.mov", "Bourky.mov", "Dest_se_snehem.mov", "Jasno.mov", "Mlhy.mov", "Mrholeni.mov", "Mrznouci_dest.mov", "Oblacno.mov", "Prehanky_dest_se_snehem.mov", "Prehanky.mov", "Skorojasno.mov", "Snehove_prehanky.mov", "Snezeni.mov", "Trvali_dest.mov", "Zatazeno.mov"];

var groupOne = mainWindow.add("group", undefined, "groupOne");

//show dropdown menu

var PH_lisabon = groupOne.add("dropdownlist", undefined, iconName);
PH_lisabon.size = [200, 25];
PH_lisabon.selection = 0;


var PH_berlin = groupOne.add("dropdownlist", undefined, iconName);
PH_berlin.size = [200, 25];
PH_berlin.selection = 0;


var PH_nice = groupOne.add("dropdownlist", undefined, iconName);
PH_nice.size = [200, 25];
PH_nice.selection = 0;

var groupTwo = mainWindow.add("group", undefined, "groupOne");
var applyButton = groupTwo.add("button", undefined, "Apply");

mainWindow.center();
mainWindow.show(); 


// this is work - app.project.item(1).replace(new File(['./ikony/' + PH_berlin.selection.text]));


//click on apply button
applyButton.onClick = function() {
    findAndReplaceIcons(PH_berlin.selection.text, "PH_berlin.mov");
    
}

// replace footage
function findAndReplaceIcons(iconOnLocation, placeHolderName) {

for (var i = 1; i <= app.project.numItems; i ++) {
    if ((app.project.item(i) instanceof FootageItem) && (app.project.item(i).name === placeHolderName)) {
    
alert(iconOnLocation);
alert(placeHolderName);
alert(app.project.item(i).name);
        app.project.item(i).replace(new File(['./ikony/' + iconOnLocation]));
        
        break;
      
      
    }
    
}

}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I believe that it is just a matter of removing the square brackets from your file path.

app.project.item(i).replace(new File(['./ikony/' + iconOnLocation]));

Should be:

app.project.item(i).replace(new File('./ikony/' + iconOnLocation));

Though I also think that it is unlikely that your attempt to use ./ for a relative reference is going to give you what you want. You may need to use something like:

var path = app.project.file.path + '/ikony/' + iconOnLocation;
app.project.item(i).replace(new File(path));
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda