# Keep Variables from reseting?

**URL:** <https://forum.kirupa.com/t/keep-variables-from-reseting/5195>\
**Category:** flash\
**Created:** [September 4, 2002, 6:14am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195 "2002-09-04T06:14:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sintax321](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@sintax321](https://forum.kirupa.com/u/sintax321)\
**Post date:** [September 4, 2002, 6:14am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/1 "2002-09-04T06:14:26Z")

</div>

I would just like to say thanxs to everyone who helped me out on my last question. From the comments posted I have been able to get FLA to work with the variable. Now I have a new problem. I can’t seem to keep the variable I set in the first frame to stop going back to zero. Instead of getting long winded in discriptions I will just post the FLA and anybody can feel free to give me some feedback if the want?

PS. FLA created in **Flash 5**

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 7:56am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/2 "2002-09-04T07:56:36Z")

</div>

Hi…

I am new with scripting… I havent tryed everything yet…

… try…

put the action script on separate layer… for entire movie…

or beter make variables global… I gues its… \_global.\<var name\> …or something…

GL.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 10:01am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/3 "2002-09-04T10:01:20Z")

</div>

I changed your fla a bit. Is this how it was supposed to work?

You needed another variable. Your ta1 watched for the rollover but the new open variable stores (obviously) if the tab is open or not. If open [COLOR=blue]open = true;[/COLOR] and if closed [COLOR=blue]open = false;[/COLOR].

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 11:13am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/4 "2002-09-04T11:13:46Z")

</div>

yeah i tested it out…it hurt my brain ☹ oh well

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 11:19am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/5 "2002-09-04T11:19:19Z")

</div>

Just a matter of elimination and those if and && statements. Can get hairy though, especially if you’ve got a lot of variables and you don’t know where they’re being set or (un?)set.

It works ok now as far as I can see.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 11:22am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/6 "2002-09-04T11:22:00Z")

</div>

well i understood all the code…my brain just hurt… ☹ oh well

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 11:36am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/7 "2002-09-04T11:36:08Z")

</div>

If that happens walk away and come back. Seriously - one time I was doing a game, and you know they say humans only use 10% of their brains? I was using 100% plus the excess red bull in my body, and when I slept - I’m not joking, I had if, ands, this.\_x, etc. filling my head.

When I woke up the first thing that came into my head was something about setProperty - since that day - I don’t take this stuff too seriously any more - not good for your health, trust me…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 3:20am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/8 "2002-09-05T03:20:10Z")

</div>

They way I have the code set up it should take care of rollover, rollout, and 2 onpress with one variable shouldin it? the rollOver and rollOut will only work if var ta1 is 0. The only time that ta1 doesn’t equal 0 is when the button has been pressed because the var ta1 is set to 1 on a press. rollOver and rollOut are disabled untill the button is pressed again returning the animation to it’s start point and setting ta1 back to 0. Is what I’m trying to do total imposiable in FLASH 5? Is there a better way to do this?:\*(

on (rollOver) {  
if (\_root.ta1 == 0) {  
\_root.top.gotoAndPlay(“rollstart”);  
}  
}  
on (rollOut) {  
if (\_root.ta1 == 0) {  
\_root.top.gotoAndPlay(“rollend”);  
}  
}  
on (press) {  
if (\_root.ta1 == 0) {  
\_root.top.gotoAndPlay(“scrollout”);  
\_root.ta1 = 1;  
}  
}  
on (press) {  
if (\_root.ta1 == 1) {  
\_root.top.gotoAndPlay(“scrollin”);  
\_root.ta1 = 0;  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 5:34am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/9 "2002-09-05T05:34:29Z")

</div>

yeah sometimes i dream in code…scary 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 7:19am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/10 "2002-09-05T07:19:18Z")

</div>

Try this one. It does what you want. If you can open the file…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 7:21am UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/11 "2002-09-05T07:21:58Z")

</div>

The problem wasn’t variables resetting, it was you needed another variable.

Let me know if there are still probs with this fla.

It’s zipped and done in Flash MX.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 1:37pm UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/12 "2002-09-05T13:37:51Z")

</div>

Flash 5 won’t open and MX file. I guess it’s not backwards compatable. Is there an option in MX to save as a Flash 5 File? I am trying to get my hands on a copy of MX so I sholud be able to open the file soon. Thanks for all your help so far.🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 6:54pm UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/13 "2002-09-05T18:54:57Z")

</div>

Here the fla saved in flash 5 format

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 11:35pm UTC](https://forum.kirupa.com/t/keep-variables-from-reseting/5195/14 "2002-09-05T23:35:31Z")

</div>

Perfect!!!=)  
I see why it needed the other variable now. I hadn’t goting as far as && statments in my book so I wasn’t sure who to set them up. Huge props to you Flex.
