Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

make alert for top layer .. what`s the error ?

Explorer ,
Jan 05, 2020 Jan 05, 2020

Copy link to clipboard

Copied

i need to make alert for top layer if his name start with 3 str  ..but any active layer change alert for example this code but not working for me it`s show one alert only

 if (doc.activeLayer[0]=_layers[i].name.substr(0,3) == "nav"){
           alert("cool")
       }else{
           
           alert("notcool");
                   
                }

 

TOPICS
Actions and scripting

Views

757
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 05, 2020 Jan 05, 2020

If you need to alert every time when the active layer is changed, use app.notifiers:

 

    if (app.notifiers.length == 0) {
       app.notifiersEnabled = true
       app.notifiers.add('slct', File($.fileName), 'Lyr ')
       } else {
        if (app.activeDocument.activeLayer.name.substr(0,3) == "nav") {
            alert("cool")
       }else{          
           alert("notcool")
       }
   }
   

 

app.notifiers.removeAll() to disable listening events (or delete record in menu File -> Scripts -> S

...

Votes

Translate
Adobe
Guide ,
Jan 05, 2020 Jan 05, 2020

Copy link to clipboard

Copied

LATEST

If you need to alert every time when the active layer is changed, use app.notifiers:

 

    if (app.notifiers.length == 0) {
       app.notifiersEnabled = true
       app.notifiers.add('slct', File($.fileName), 'Lyr ')
       } else {
        if (app.activeDocument.activeLayer.name.substr(0,3) == "nav") {
            alert("cool")
       }else{          
           alert("notcool")
       }
   }
   

 

app.notifiers.removeAll() to disable listening events (or delete record in menu File -> Scripts -> Scripts event manager

 

if you need to check only the name of the top layer, its index is always 0, i.e.:

 

if (app.activeDocument.layers[0].name.substr(0,3) == "nav"){
           alert("cool")
       }else{
           
           alert("notcool");
                   
                }

 

 

(not sure I understood the question correctly 🙂

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines