00:00
00:00
Newgrounds Background Image Theme

Mekatov just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS, A little challenge for ya'll...

1,533 Views | 23 Replies
New Topic Respond to this Topic

Allright people..... I've got a little problem with an actionscript..... here it comes....

onClipEvent(load){
speed=10; stop();
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)){_x+=speed; gotoAndStop(1);}
if (Key.isDown(Key.DOWN)){_y+=speed; gotoAndStop(2);}
if (Key.isDown(Key.LEFT)){_x-=speed; gotoAndStop(3);}
if (Key.isDown(Key.UP)){_y-=speed; gotoAndStop(1);}
}

It's from the AS: BASIC MOVEMENT forum, for those who can find the part that is wrong in this script, pat yourself on the back =), I allready knew it, and that's not the point... Frame 1, 2, 3 and (in this script) 1.... (yup, that's it, should be 4...) Are WALKING animations, how do I make my character like, play frame 5 if I release Right??

Thank ya'll in advance <3
Erik from Dipshit Productions

Response to AS, A little challenge for ya'll... 2005-10-08 06:32:20


It's obvious, both UP and RIGHT are gotoAndPlay(1);
and 1 should be standing still.


BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 06:32:57


one word for you, "else"

read AS: Conditions and Loops

Response to AS, A little challenge for ya'll... 2005-10-08 06:33:40


At 10/8/05 06:30 AM, Dipshitprod wrote: It's from the AS: BASIC MOVEMENT forum, for those who can find the part that is wrong in this script, pat yourself on the back =), I allready knew it, and that's not the point... Frame 1, 2, 3 and (in this script) 1.... (yup, that's it, should be 4...) Are WALKING animations, how do I make my character like, play frame 5 if I release Right??

Damn, I've misread :P
just turn "gotoAndPlay(1);" to "gotoAndPlay(5);" knowing that the number is the frame number.


BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 06:43:28


At 10/8/05 06:32 AM, -Toast- wrote: It's obvious, both UP and RIGHT are gotoAndPlay(1);
and 1 should be standing still.

ehm... no...
the final gotoAndPlay should be 4, and 1, 2, 3 and 4 are walking, so tell me, how do I let my MC go to frame 5 if I release Right, go to frame 6 if I release Down, go to 7 if I release Left and go to 8 if I release Up????

Response to AS, A little challenge for ya'll... 2005-10-08 06:47:15


7,777 posts Inglor! Woo..

Response to AS, A little challenge for ya'll... 2005-10-08 06:55:32


At 10/8/05 06:47 AM, GuntherSwanh wrote: 7,777 posts Inglor! Woo..

oooooooooooooooo..k.... is that me, or was that off-topic? =/

Response to AS, A little challenge for ya'll... 2005-10-08 06:56:56


At 10/8/05 06:47 AM, GuntherSwanh wrote: 7,777 posts Inglor! Woo..

Pff... Don't bother...

Toast says:
you forgot about your 7777 post!
Inglor - Armor Games says:
so?
Toast says:
you should have yayed it
Inglor - Armor Games says:
naa
Inglor - Armor Games says:
I'm waiting for 10K to do something funny, unless I miss it or something


BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 06:57:24


READ AS CONDITIONS AND LOOPS AND READ ABOUT "else" STATEMENTS, sometimes I'm getting the feeling noone is paying attn...

Response to AS, A little challenge for ya'll... 2005-10-08 07:00:47


At 10/8/05 06:57 AM, Inglor wrote: READ AS CONDITIONS AND LOOPS AND READ ABOUT "else" STATEMENTS, sometimes I'm getting the feeling noone is paying attn...

Inglor, I did, the problem is, it didn't help out this time =(
I'm not that much a n00b that I don't mind some posts ;)

Response to AS, A little challenge for ya'll... 2005-10-08 07:01:58


if(left){
face left
}else if(right){
face right
}... ... else{
face idle
}

Response to AS, A little challenge for ya'll... 2005-10-08 07:09:35


What about this:

else if (!Key.isDown(Key.LEFT)) {
gotoAndStop(1);
}

Wouldnt that work?


"Actually, the server timed out trying to remove all your posts..."

-TomFulp

Response to AS, A little challenge for ya'll... 2005-10-08 07:10:53


At 10/8/05 07:01 AM, Inglor wrote: if(left){
face left
}else if(right){
face right
}... ... else{
face idle
}

Sorry that isn't working, The version like this, or an edited gotoAndStop version with all the right frames filled in......Maybe this helps.....

onClipEvent(load){
speed=10; stop(); dir=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)){
_x+=speed; gotoAndStop(2); dir=0;
}else if (Key.isDown(Key.LEFT)){
_x-=speed; gotoAndStop(3); dir=1;
}else{
if (dir==0){
gotoAndStop(1);
}else{
gotoAndStop(4);
}
}
}

This is for a side scrolling game...Can anybody change this into four movement???

Response to AS, A little challenge for ya'll... 2005-10-08 07:14:30


At 10/8/05 07:10 AM, Dipshitprod wrote: This is for a side scrolling game...

Ah, that reminds me that i need to finish off my sidescrolling engine.

Response to AS, A little challenge for ya'll... 2005-10-08 07:16:12


At 10/8/05 07:09 AM, IWantSomeCookies wrote: What about this:

else if (!Key.isDown(Key.LEFT)) {
gotoAndStop(1);
}

Wouldnt that work?

Did you evern READ the post?I knew that, I even solved a problem in that script from AS-Movement-Basic..... what I want to know is how to make it go to frame 5 when I release the key right, like this,

if I press right, play frame 1 (walking right)
if I press down, play frame 2 (walking down)
if I press left, play frame 3 (walking left)
if I press up, play frame 4 (walking up)
------------------------------------------
---------------------^Allready know script for that^
if I take my finger off right, play frame 5 (standing still, facing right)
if I take my finger off down, play frame 6 (standing sitll, facing down)
if I take my finger off left, play frame 7 (standing still, facing left)
if I take my finger off up, play frame 8 (standing still, facing up)
------------------------------------------
------------------------------------------
-----------^Problemo^

I know you only want to help... but seriously....

Response to AS, A little challenge for ya'll... 2005-10-08 07:26:44


Try this (untested)

onClipEvent(load){
speed=10; stop(); dir=1;moving=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)){moving=1; dir=1;}
else if (Key.isDown(Key.DOWN)){moving=1; dir=2;}
else if (Key.isDown(Key.LEFT)){moving=1; dir=3;}
else if (Key.isDown(Key.UP)){moving=1;dir=4;}
else{moving=0;}

if(moving){
gotoAndPlay(dir);
}else{
gotoAndPlay(dir+4);
}

}


- - Flash - Music - Images - -

BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 07:28:02


At 10/8/05 07:26 AM, Denvish wrote: Try this (untested)

You probably want to change the gotoAndPlays to gotoAndStops :P


- - Flash - Music - Images - -

BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 07:31:09


People make mistakes, and you my friend are in no position to go off aobut people not reading posts. There is a good way of using else here, which I can't be bothered to type - Denvish has the way I'd do it though.


I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

Response to AS, A little challenge for ya'll... 2005-10-08 07:32:54


Yup, that one works.....but there is only one problem with it (no offense meant) when I apply this script, it works perfectly, but the movements turn into non-moving graphics.... so, like frame 1 is moving right, when I release it, it goes to frame 5, good, but the movie clip in frame one (in the movie clip character) holds still, it only shows the first frame of the mc in the character =/, so like, it holds still, I press right, it sets one step (the first frame of the mc) and then the mc stops.... =/

Response to AS, A little challenge for ya'll... 2005-10-08 07:36:16


At 10/8/05 07:28 AM, Denvish wrote:
At 10/8/05 07:26 AM, Denvish wrote: Try this (untested)
You probably want to change the gotoAndPlays to gotoAndStops :P

Ah allright, ignore my last post then, thank you all for helping me out!! you have no idea how glad I am ^^ Thank you all agian a 999999999-infinity (-infinity is an as part i found in the index, it seemed a fun joke to me) times!

-Erik from Dipshitproductions

Response to AS, A little challenge for ya'll... 2005-10-08 07:40:29


Hmmm, that's because it's continually jumping to the frame. Try holding the original frames 'dir' in the variable 'olddir' and checking before the gotoAndStop. Not the cleanest way, but it should work. Bear in mind I haven't got Flash open, so I'm just making this up... =P

onClipEvent(load){
speed=10; stop(); dir=1; olddir=1;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)){moving=1; dir=1;}
else if (Key.isDown(Key.DOWN)){moving=1; dir=2;}
else if (Key.isDown(Key.LEFT)){moving=1; dir=3;}
else if (Key.isDown(Key.UP)){moving=1;dir=4;}
else{moving=0;}

if(moving){
if(dir!==olddir){
gotoAndStop(dir);
}
}else{
gotoAndStop(dir+4);
}
olddir=dir;
}


- - Flash - Music - Images - -

BBS Signature

Response to AS, A little challenge for ya'll... 2005-10-08 11:56:05


At 10/8/05 07:16 AM, Dipshitprod wrote:
Did you evern READ the post?

Yes, and that is what it is. There is a '!' at the beginning of the code, which means like "if bla bla is not pressed" ?


"Actually, the server timed out trying to remove all your posts..."

-TomFulp

Response to AS, A little challenge for ya'll... 2005-10-08 12:09:28


sorry, there wasn't a ! and a ! means "not"

Response to AS, A little challenge for ya'll... 2005-10-08 13:07:57


At 10/8/05 06:47 AM, GuntherSwanh wrote: 7,777 posts Inglor! Woo..

Do you think inglor will die when he reaches 10 000 posts? I hope not.