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
var layersArray = dom.layers;
alert(layersArray.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.
jelaplan at yahoo
It turns out that the dom variable that I was using was not up-to-date
var dom = fw.getDocumentDOM();
alert(dom.layers.name) // This shows the first layer of the previous Page
alert(fw.getDocumentDOM().layers.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.
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.