Be a Supporter!

AS 2 help

  • 211 Views
  • 3 Replies
New Topic Respond to this Topic
Vilezz
Vilezz
  • Member since: Jul. 28, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
AS 2 help 2009-07-28 18:57:08 Reply

Ok so basicly i know nothing about AS and seeing as nobody wants to help me make my game, im going to try to learn.

how would i write something like:

on press up key move up at speed X
on press right key move right at speed X
on press left key move left at speed X
on press down key move down at speed X

But then for example so you dont walk into the air or ground how would i write,
if "instance name" moves above x=100 do not allow?

Also how do i make it play a certain mc when i press a button, eg when i press right it turns right?

Thanks.

Magical-Zorse
Magical-Zorse
  • Member since: May. 10, 2008
  • Offline.
Forum Stats
Member
Level 40
Melancholy
Response to AS 2 help 2009-07-28 19:05:26 Reply

this is to move. put this in a movieclip

onClipEvent (load) {
	speed = 6;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.UP)) {
		_y -= speed;
	}
	if (Key.isDown(Key.DOWN)) {
		_y += speed;
	}
	if (Key.isDown(Key.LEFT)) {
		_x -= speed;
	}
	if (Key.isDown(Key.RIGHT)) {
		_x += speed;
	}
}

BBS Signature
Vilezz
Vilezz
  • Member since: Jul. 28, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to AS 2 help 2009-07-28 19:13:35 Reply

At 7/28/09 07:05 PM, Magical-Zorse wrote: this is to move. put this in a movieclip

onClipEvent (load) {
speed = 6;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= speed;
}
if (Key.isDown(Key.DOWN)) {
_y += speed;
}
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
}

Thanks, I guess thats self explanatory as in what it does (im trying to learn AS) but why do you have the indent thing on some of the lines but not on the top ones? Does it have to be there for it to work and what button is it?

mkmetalhead
mkmetalhead
  • Member since: Aug. 9, 2008
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS 2 help 2009-07-28 20:06:16 Reply

Thanks, I guess thats self explanatory as in what it does (im trying to learn AS) but why do you have the indent thing on some of the lines but not on the top ones? Does it have to be there for it to work and what button is it?

The indent does itself, it basically makes it easier to check you've done everything right. Don't worry about it, you can auto-format with the format button.