Be a Supporter!

Settings menu AS2

  • 231 Views
  • 2 Replies
New Topic Respond to this Topic
Thundaboom
Thundaboom
  • Member since: Jan. 24, 2009
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Settings menu AS2 2010-05-13 22:34:26 Reply

So I have a menu. It's _alpha can be triggered with the space bar function.

onClipEvent(enterFrame){
 if(Key.isDown(Key.SPACE)){
  _alpha = 100;
 }
}

Then I want to make it have a variable so it knows when to trigger it. I did so.

onClipEvent(load){
 var active:Boolean = false;
}
onClipEvent(enterFrame){
 if(Key.isDown(Key.SPACE) && active == false){
   _alpha = 100;
  active = true;
 }
 else if(Key.isDown(Key.SPACE) && active == true){
  _alpha = 0;
  active = false;
 }
}

Presumably, it works. But it glitches. Since it keeps on looping to true and false, it's just plain non-usable.

Is there any way to make it so I can still hold space BUT still have the setting's alpha be 100 and then I press space AGAIN to do that?

Thanks, it would be a great help if you could help me find out what the problem is.


No!

Bum-Secks
Bum-Secks
  • Member since: Oct. 12, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Settings menu AS2 2010-05-13 23:08:36 Reply

i just started programming a couple weeks go, so this is probably the noobiest fix ever:

onClipEvent(load){
active = false;
space = 1;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.SPACE)&&space==1&&acti ve==false){
_alpha = 100;
active = true;
}
if(!Key.isDown(Key.SPACE)&&active==true)
{
space=2;
}
if(Key.isDown(Key.SPACE)&&space==2&&acti ve==true){
_alpha = 0;
active = false;
}
if(!Key.isDown(Key.SPACE)&&active==false ){
space=1;
}
}

Bum-Secks
Bum-Secks
  • Member since: Oct. 12, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Settings menu AS2 2010-05-13 23:12:52 Reply

woops, how do you post a code without the forum fking it up? like this?

onClipEvent(load){
active = false;
space = 1;
}
onClipEvent(enterFrame){
 if(Key.isDown(Key.SPACE)&&space==1&&active==false){
   _alpha = 100;
  active = true;
 }
 if(!Key.isDown(Key.SPACE)&&active==true){
	 space=2;
 }
 if(Key.isDown(Key.SPACE)&&space==2&&active==true){
  _alpha = 0;
  active = false;
 }
 if(!Key.isDown(Key.SPACE)&&active==false){
	 space=1;
}
}