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

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

Explorer ,
Jan 05, 2020 Jan 05, 2020

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
824
Translate
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

Mentor , 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

...
Translate
Adobe
Mentor ,
Jan 05, 2020 Jan 05, 2020
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 🙂

Translate
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