The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:36 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 5 posts ] 
Actionscript help please 
Author Message

Joined: Wed Jul 07, 2010 8:57 pm
Posts: 21
Gender: Anime Girl
i need help with some coding i tried to get a mario sprite to run by pressing the left and right arrow keys but when you press the left one mario turns upside down here is the code


var speed = 5

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
mariodash._x+= speed
mariodash._rotation=360
}
if(Key.isDown(Key.LEFT)){
mariodash._x-= speed
mariodash._rotation=180
}

any help is appreciated and please don't laugh at me this is my first time trying actionscript without a tutorial
};

_________________
previous names:Mr.Mario123

http://spamtheweb.com/ul/s1172010271_ssj4goku.html
any constructive criticism please, please send as pm

http://spamtheweb.com/ul/s1372010246_MLvsShadow.html
it won't let me on imageshack


Notorio wrote:
ElvisDitto wrote:
Thaiberium wrote:

I'm a kiss-ass! +1 post!


You're right, math is wrong. Fix it.


SSF2 Mains:Mario,Luigi,Goku,Ichigo,Naruto,Sonic,Lloyld (sorry if i didn't spell right) not in order from fav main to least fav main


Fri Jul 16, 2010 7:04 pm
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
Mr.Mario123 wrote:
i need help with some coding i tried to get a mario sprite to run by pressing the left and right arrow keys but when you press the left one mario turns upside down here is the code


var speed = 5

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
mariodash._x+= speed
mariodash._rotation=360
}
if(Key.isDown(Key.LEFT)){
mariodash._x-= speed
mariodash._rotation=180
}

any help is appreciated and please don't laugh at me this is my first time trying actionscript without a tutorial
};

first off your _rotation is why its turning upside down

make a var called scale

var scale:Number = _xscale;

then in your right key if statement put this

mariodash._xscale = scale;

and then in your left put this

mariodash._xscale = -scale;

this should help with the turning
if the character faces the wrong way just switch the codes
hope it helps

_________________
get free wii points here!


Sat Jul 17, 2010 3:13 pm

Joined: Wed Jul 07, 2010 8:57 pm
Posts: 21
Gender: Anime Girl
**Error** Scene=Scene 1, layer=script, frame=1:Line 2: A type identifier is expected after the ':'.
var scale: 360 = _xscale

Total ActionScript Errors: 1 Reported Errors: 1

this is what it said maybe i made a mistake

var speed = 10
var scale: 360 = _xscale

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
mariodash._x+= speed
mariodash._xscale = scale;
}
if(Key.isDown(Key.LEFT)){
mariodash._xscale = -scale;
mariodash._x-= speed
}
};

thanks for the help i thought that no one was going to reply me being a newbie

_________________
previous names:Mr.Mario123

http://spamtheweb.com/ul/s1172010271_ssj4goku.html
any constructive criticism please, please send as pm

http://spamtheweb.com/ul/s1372010246_MLvsShadow.html
it won't let me on imageshack


Notorio wrote:
ElvisDitto wrote:
Thaiberium wrote:

I'm a kiss-ass! +1 post!


You're right, math is wrong. Fix it.


SSF2 Mains:Mario,Luigi,Goku,Ichigo,Naruto,Sonic,Lloyld (sorry if i didn't spell right) not in order from fav main to least fav main


Sat Jul 17, 2010 10:22 pm
User avatar

Joined: Sat Aug 23, 2008 3:10 am
Posts: 2601
Location: Australia - Sydney
Gender: Male
Currently Playing: Ninja Gaiden III
Newbs' problems are easier to fix.

_________________
Image


Sun Jul 18, 2010 7:48 am
WWW
Site Moderator
User avatar

Joined: Fri May 22, 2009 3:44 pm
Posts: 4156
Location: saying things with posed looks
Gender: Anime Girl
Skype: Snail's Legacy
Currently Playing: umib and unib
Waifu: SNAIL
Mr.Mario123 wrote:
**Error** Scene=Scene 1, layer=script, frame=1:Line 2: A type identifier is expected after the ':'.
var scale: 360 = _xscale

Total ActionScript Errors: 1 Reported Errors: 1

this is what it said maybe i made a mistake

var speed = 10
var scale: 360 = _xscale

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
mariodash._x+= speed
mariodash._xscale = scale;
}
if(Key.isDown(Key.LEFT)){
mariodash._xscale = -scale;
mariodash._x-= speed
}
};

thanks for the help i thought that no one was going to reply me being a newbie




take out 360 and put Number so the code looks like this:


var speed = 10
var scale: Number = _xscale

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
mariodash._x+= speed;
mariodash._xscale = scale;
}
if(Key.isDown(Key.LEFT)){
mariodash._xscale = -scale;
mariodash._x-= speed;
}
}


i took the liberty of correcting some wrongs you had in there.

_________________
Image

Image Image Image

early 2k nostalgia mode


Wed Aug 04, 2010 9:34 pm
Display posts from previous:  Sort by  
 [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.