2 Replies Latest reply on Dec 8, 2009 9:01 AM by jelaplan

    Programmaticly switching Pages and accessing layers: JSF Script

    jelaplan Level 1

      I want to programmically switch Pages and then access the layers for that Page. But, I find that the dom.layers object doesn't get updated when I call changeCurrentPage

       

      fw.getDocumentDOM().changeCurrentPage(0)

      var layersArray = dom.layers;

      alert(layersArray[0].name) // This shows the first layer of the previous Page

       

      I could see some value in not updating the dom.layers - for example, if I wanted to refer to the layers on the previous page and copy them. But, in my case, I want to operate on the layers associated with the Page that I switch to.

       

       

      John laPlante

      jelaplan at yahoo

        • 1. Re: Programmaticly switching Pages and accessing layers: JSF Script
          jelaplan Level 1

          It turns out that the dom variable that I was using was not up-to-date

           

          var dom = fw.getDocumentDOM();

          fw.getDocumentDOM().changeCurrentPage(0)

          alert(dom.layers[0].name) // This shows the first layer of the previous Page

          alert(fw.getDocumentDOM().layers[0].name // This shows the first layer of the current Page

           

          Much thanks goes out to Sarthak an Adobe engineer who often blogs about Fireworks.

           

          This says something about the way variables are assigned. In my original code, the dom variable is a reference to the dom rather than to the call to get the dom. I didn't expect that but good to know for the future. It is also useful to know that I can potentially refer to the dom of any Page regardless of whether that Page is shown.

          • 2. Re: Programmaticly switching Pages and accessing layers: JSF Script
            jelaplan Level 1

            BTW, in trying to loop over Pages, I had trouble finding a Pages object to use to reference pages, their length, index etc. In looking on google, I ran across Aaron Beall's awesome site and found the following properties which did the trick. These are not documented in fireworks_cs3_extending.pdf or the online version for CS4.

             

            fw.getDocumentDOM().pagesCount
            fw.getDocumentDOM().currentPageNum