# Variable/Function advice

**URL:** <https://forum.kirupa.com/t/variable-function-advice/247133>\
**Category:** flash\
**Created:** [December 18, 2007, 8:53pm UTC](https://forum.kirupa.com/t/variable-function-advice/247133 "2007-12-18T20:53:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geminione](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@geminione](https://forum.kirupa.com/u/geminione)\
**Post date:** [December 18, 2007, 8:53pm UTC](https://forum.kirupa.com/t/variable-function-advice/247133/1 "2007-12-18T20:53:37Z")

</div>

I’m setting up a document similar to a website. Say six buttons linking to six sections. I initially wrote a function to move “x stage” into view while removing whatever else was showing at the time. So it looked something like this (which works):

```auto

home = function () {
	setProperty(this.stage1, _x, 0);
	setProperty(this.stage1, _visible, 1);
	setProperty(this.stage2, _x, -1025);
	setProperty(this.stage2, _visible, 0);
	setProperty(this.stage3, _x, -1025);
	setProperty(this.stage3, _visible, 0);
	setProperty(this.stage4, _x, -1025);
	setProperty(this.stage4, _visible, 0);
	setProperty(this.stage5, _x, -1025);
	setProperty(this.stage5, _visible, 0);
};

```

Now I had that repeated for each stage adjusting the property for each one. Pain. I started thinking … wait … if we add more pages, that’s a ton to write. So then I thought … maybe I could set it up so the button would tell the function what stage to set … then I’m not so sure about that, but anyways.

Does anyone have advice on the best way to write this? Should I use a variable defined by a button to swap out “stages”. I looked into loading them from the library, but it screwed up some of the components I’m using. There has to be an easier way.

Thanks for any advice.
