Hi,
i'm stuck with something i thought would be easy to achieve.
I created a little app based on Alloy with four windows/views which are all using full screen size. Let's call them a, b, c and d. On startup 'a' is the visible view.
What i want is when i slide 'a' to the left i want 'b' to appear under it. Now 'b' is visible and when i slide it to the left i want 'a' to reappear again.
But when i slide 'a' or 'b' to the right i want it to reveal 'c' and when 'c' is slided to the right i want 'd' to be revealed. (Hope this is not too confusing)
I thought i could achieve this with four views/windows and manipulating the zIndex. But it seems that the zIndex does nothing to the view/windows.
Next i tried to use setVisible, but that also doesn't change anything.
I am using createController and getView to access the views, is this the problem? Because when i check the manipulated attributes (zIndex or visible) of the view, they are returned as i am expecting them, but in the app the effect is not visible.
Any hints how this could be realized?
Thanks in advance, regards Joe.
PS: I'm testing this with the iOS Simulator and SDK 2.1.4
1 Answer
Accepted Answer
OK, there's one major thing wrong here. Don't call createController in your event handler. That is creating a new instance of the controller each time, which I'm certain is not what you are meaning to do. Instead, use the index controller to delegate messages between your a and b controllers.I took the liberty of implementing your example (FYI, this is what I mean by a test case). I've tested it and it works as you would expect.
index.xml<Alloy>
<Window backgroundColor="#fff">
<Require src="a" id="a" onButtonClick="moveAToBack"/>
<Require src="b" id="b" onButtonClick="moveBToBack"/>
</Window>
</Alloy>
index.jsvar a = $.a.getView();
var b = $.b.getView();
function moveAToBack() {
a.zIndex = 1;
b.zIndex = 10;
}
function moveBToBack() {
a.zIndex = 10;
b.zIndex = 1;
}
$.index.open();
a.xml & b.xml<Alloy>
<View class="container">
<Button onClick="moveToBack">press me</Button>
</View>
</Alloy>
a.js & b.jsfunction moveToBack() {
$.trigger('buttonClick');
}
a.tss".container": {
backgroundColor: '#f00'
}
b.tss".container": {
backgroundColor: '#00f'
}
Your Answer
Think you can help? Login to answer this question!