The problem is that there is no instance of "object1" in the layout where the events happen.
So basicly, the instance variable doesn't exist and indeed returns 0.
Also, you should pay attention to the window size, which is bigger than the layouts size (never a good idea).
If you set the correct events in layout 1 you can see things work like in this capx
You need to create an instance of the array in the first layout (as the array was created only in the second layout).
If you want to continue with a similar setting I strongly suggest you to start a project from scratch and create the array in the first layout (of execution) as you'll probably want it to be global to have only one instance storing values through all layouts.