Forum Topic: Dammit AS! Work for me!

(202 views • 7 replies)

This topic is 1 page long.

<< < > >>
Angry

neon-dude

Reply To Post Reply & Quote

Posted at: 8/15/08 10:15 AM

neon-dude LIGHT LEVEL 09

Sign-Up: 03/15/06

Posts: 752

Yeah well, in short I'm trying to get an MC to move around a bit. Usualy I'd just use tweens etc. but this time I decided to be uber 1337 and do it in AS. But it won't bloody work! Here's my script, halp please!

onClipEvent (load) {
	left = false;
}
onClipEvent (enterFrame) {
	if (left=false) {
		this._x += 5;
	}
	if (left=true) {
		this._x += 5;
	}
	if (this._x=1571.7) {
		left = true;
	}
	if (this._x=571.7) {
		left = false;
	}
}

"just because idiots are great in number does not mean they're not idiots" - alicetheDroog
The Atheist Army|English Gentleman's Club
Sig censored by: SevenSeize

BBS Signature

None

LonLonRanch

Reply To Post Reply & Quote

Posted at: 8/15/08 10:18 AM

LonLonRanch LIGHT LEVEL 17

Sign-Up: 05/22/05

Posts: 320

gotta look out for those double equal signs :D

onClipEvent (load) {
	left = false;
}
onClipEvent (enterFrame) {
	if (left==false) {
		this._x += 5;
	}
	if (left==true) {
		this._x += 5;
	}
	if (this._x==1571.7) {
		left = true;
	}
	if (this._x==571.7) {
		left = false;
	}
}

Happy

Hotwired05

Reply To Post Reply & Quote

Posted at: 8/15/08 10:18 AM

Hotwired05 EVIL LEVEL 12

Sign-Up: 03/19/08

Posts: 288

you cant just say "left"

in the begginig you do

if (Key.isDown)(Key.LEFT){
this."YOUR SCRIPT OF MOVEMENT HERE"
it has to envolve X or Y and like this.X=-5 this will move it -5 on the X axis....

This is a GREAT website...go there and see for yourself...just sign up below and your on your way
HERE

BBS Signature

None

Vengeance

Reply To Post Reply & Quote

Posted at: 8/15/08 10:18 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,035

Using the = sign DEFINES a value, whilst using a == sign checks equility.
so by saying

if(left=true){

You're defining left to be true.
You need to say

if(left==true){
//blah
}

You also need to do the same for the coordinates.

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

None

KyleDaFox

Reply To Post Reply & Quote

Posted at: 8/15/08 10:22 AM

KyleDaFox LIGHT LEVEL 25

Sign-Up: 04/23/05

Posts: 2,144

Something like this

onClipEvent (load) {
	left = false;
}
onClipEvent (enterFrame) {
	if (left == false) {
		this._x += 5;
	}
	if (left == true) {
		this._x -= 5;
	}
	if (this._x<=0) {
		left = false;
	}
	if (this._x>=550) {
		left = true;
	}
}

You can change around when it += or -=, and the _x and _y values, I did it to test it.

It's basically what Vengeance said, but unless your _x coordinates end in .7 and can be hit exactly, it won't work.

That's the reason I put in >= and <=, they see if something is greater than or equal to, or less than or equal to the number after.

Questions?

Check out my newest News Post!
Anyone need an artist or coder for a game? Drop me a PM!

BBS Signature

None

rickeyricksricky

Reply To Post Reply & Quote

Posted at: 8/15/08 10:23 AM

rickeyricksricky LIGHT LEVEL 03

Sign-Up: 08/12/08

Posts: 83

At 8/15/08 10:18 AM, Hotwired05 wrote: you cant just say "left"

in the begginig you do

if (Key.isDown)(Key.LEFT){
this."YOUR SCRIPT OF MOVEMENT HERE"
it has to envolve X or Y and like this.X=-5 this will move it -5 on the X axis....

The "+" n' "-" sign always need to be in front of the "=" sign. ;)


None

neon-dude

Reply To Post Reply & Quote

Posted at: 8/15/08 10:27 AM

neon-dude LIGHT LEVEL 09

Sign-Up: 03/15/06

Posts: 752

At 8/15/08 10:18 AM, Vengeance wrote: Using the = sign DEFINES a value, whilst using a == sign checks equility.
so by saying

if(left=true){

You're defining left to be true.
You need to say

if(left==true){
//blah
}

You also need to do the same for the coordinates.

oh damm, I knew that but I completely forgot about it thanks for reminding me :)

"just because idiots are great in number does not mean they're not idiots" - alicetheDroog
The Atheist Army|English Gentleman's Club
Sig censored by: SevenSeize

BBS Signature

None

neon-dude

Reply To Post Reply & Quote

Posted at: 8/15/08 10:32 AM

neon-dude LIGHT LEVEL 09

Sign-Up: 03/15/06

Posts: 752

At 8/15/08 10:18 AM, Hotwired05 wrote: you cant just say "left"

in the begginig you do

if (Key.isDown)(Key.LEFT){
this."YOUR SCRIPT OF MOVEMENT HERE"
it has to envolve X or Y and like this.X=-5 this will move it -5 on the X axis....

no, this MC isn't on you control, it just moves around between two points.

"just because idiots are great in number does not mean they're not idiots" - alicetheDroog
The Atheist Army|English Gentleman's Club
Sig censored by: SevenSeize

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 04:26 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!