Be a Supporter!

Action Script 2.0 Help

  • 306 Views
  • 8 Replies
New Topic Respond to this Topic
AwesomeIam
AwesomeIam
  • Member since: Feb. 7, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Action Script 2.0 Help 2009-05-04 16:20:40 Reply

I'm making a game and I need a code that places a lock over a button if the the kills are't high enough. In the lock movie clip I have these actions

onClipEvent(enterFrame){
	if(kills < 10){
		this._x = US._x;
		this._y = US._y;
	}
}

And on the frame I have this

stop();

kills = 0;

What am I doing wrong?


BBS Signature
ColdLogic
ColdLogic
  • Member since: Nov. 12, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:32:24 Reply

onClipEvent(enterFrame){
if(kills < 10){
this._x = US._x;
this._y = US._y;
}
}

try changeing the if to:

if(_root.kills <10){

wasup12
wasup12
  • Member since: Dec. 16, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:33:57 Reply

At 5/4/09 04:20 PM, AwesomeIam wrote: I'm making a game and I need a code that places a lock over a button if the the kills are't high enough. In the lock movie clip I have these actions

onClipEvent(enterFrame){
if(kills < 10){
this._x = US._x;
this._y = US._y;
}
}

And on the frame I have this

stop();

kills = 0;

What am I doing wrong?

The MovieClip does not see the variable in the main frame. You need to make it a global variable, which is not usually recommended because it slows the program down if it is big. But instead of kills = 0 put...

_global.kills = 0

Put that on the frame, and also in the if statement. (of course without the = sign though, you know)

_global.kills

The Game

AwesomeIam
AwesomeIam
  • Member since: Feb. 7, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:45:50 Reply

At 5/4/09 04:33 PM, wasup12 wrote:
The MovieClip does not see the variable in the main frame. You need to make it a global variable, which is not usually recommended because it slows the program down if it is big. But instead of kills = 0 put...

_global.kills = 0

Put that on the frame, and also in the if statement. (of course without the = sign though, you know)

_global.kills

I tried that and I also tired ColdLogics method. Even a combinations of the two. It just doesn't seem to work... = [


BBS Signature
AwesomeIam
AwesomeIam
  • Member since: Feb. 7, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:52:38 Reply

no no no! Wait wait! I figured it out! Thanks guys.


BBS Signature
wasup12
wasup12
  • Member since: Dec. 16, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:53:42 Reply

No... you don't put _root. in front of a variable, I am sure of that, try just _global.kills


The Game

4urentertainment
4urentertainment
  • Member since: Aug. 1, 2008
  • Offline.
Forum Stats
Moderator
Level 13
Game Developer
Response to Action Script 2.0 Help 2009-05-04 16:54:36 Reply

At 5/4/09 04:53 PM, wasup12 wrote: No... you don't put _root. in front of a variable, I am sure of that, try just _global.kills

No, it's _root.

I've tested it, it works.

ColdLogic
ColdLogic
  • Member since: Nov. 12, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 16:57:53 Reply

hurray for me! now i have to drink a beer.

wasup12
wasup12
  • Member since: Dec. 16, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Action Script 2.0 Help 2009-05-04 17:04:48 Reply

At 5/4/09 04:54 PM, 4urentertainment wrote:
At 5/4/09 04:53 PM, wasup12 wrote: No... you don't put _root. in front of a variable, I am sure of that, try just _global.kills
No, it's _root.

I've tested it, it works.

Really? By golly now I can properly define global variables! lol

var speedGuy:Number = 3;

Cheers.


The Game