[FMX] Giving and reading a variable?

Hi,

On this moment I have a menu and six windows, every item on the menu has his own window. What I would like to do is that when the item ‘home’ is viewable and the visitor has pressed on another item, the window of ‘home’ goes away and the item were is clicked on comes up.

But how can I do that the best?
I think I must give every window a variable so when there is pressed on a item flash will go search for the window that is shown and let that one play the animation to go away, so the window that is shown must have variable ‘1’ all the others are ‘0’ and when pressed on a item flash search for ‘1’…
But how do I do all this, and is this a good way of working??

I hope somebody can help me with this issue!

Thanks in advance,
mykingdom*****

allright, the solution to this is xactly what you think…

first of all, you need to know wich window needs to be active, by putting this simple action on each button


on(release){
	_global.activewindow=X
}

where X = the active window number

so, when you click each button we know wich screen we need, now on to the screens,

inside every screen, lets say we make an animation with 10 frames, with 1 and 10 being the active state(visible), and 5 the inactive state (invisible), create an nice animation in those 4 frames, lets say a simple alpha change…

now we have an animation, but it keeps playing if you let it run, so you will need to add 2 stop actions, 1 on the visible state (frame 1) and 1 on the invisible state (frame 5)

repeat this untill you have your windows…

now we need an script that will allow us to view only 1 window at the same time,

select a window, and press F2 (actions) and copy/paste this code:


onClipEvent (enterFrame) {
	if (_global.activewindow == X) {
		if (_currentframe != 1) {
			play();
		}		
	} else {
		if (_currentframe != 5) {
			play();
		}
	}
}

where X is the window number

this code will repeat every frame, so if you have an FPS of 40, it will repeat it 40 times a second (duh)

first it will check if the number is the assign value, if that is true, it will check if the current window isn’t already active, if not, play untill its active…

if its NOT the number he wants, it will play untill its invisible…

easy huh?

here’s the .fla to