title: Illustrator script: Selecting objects in layer
body: <p>So I have a script that should select the objects of a layer and deselect it afterwards. (adobe Illustrator)</p>
  
  <p>But for some reason after it deselects, it automaticly selects an object that doesn't appear anywhere in my layers together with the next selected object.</p>
  
  <p>What could this be?</p>
  
  <pre><code>myDoc = app.activeDocument;
  myLayers = myDoc.layers;
  
  for (var a=0; a&lt;myLayers.length; a++)
  {
      //Select objects in layer
      myLayers[a].hasSelectedArtwork = true;
  
      //Do action here
  
      //Deselect objects in layer
      myLayers[a].hasSelectedArtwork = false;
  }
  </code></pre>