Be a Supporter!

Action Script Help?

  • 438 Views
  • 14 Replies
New Topic Respond to this Topic
Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Action Script Help? 2007-06-23 22:16:59 Reply

Hmm.. ok.. i suck at action script and would like something like this working:
When key (the key i want to be pressed) is pressed, go to bla bla bla!
When key (The key that was pressed) as been released, go to bla bla bla!

Could sum1 help me? plz? if not just dont reply.. no need to tell me i suck or stuff like that..

Kart-Man
Kart-Man
  • Member since: Jan. 7, 2007
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to Action Script Help? 2007-06-23 22:20:34 Reply

Try using a combination of if and else statements.

onClipEvent (enterFrame) {
if (Key.isDown (Key.INSERTKEYHERE)) {
gotoAndPlay ("blah");
}else{
gotoAndPlay ("anotherblah");
}
}


postcount +=1;
Newgrounds Photoshop Headquarters || Don't use MS Paint! Use Aviary!
SING US A SING YOU'RE THE PIANO MAN

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Action Script Help? 2007-06-23 22:20:45 Reply

What do you mean "go to blah blah blah"
What do you want to happen when those Keys are pressed?
An object moves? It goes to a different part of your movie?
Noo idea what you're trying to accomplish.
Also, might I suggest looking here first AS: Main


AS: Main

Don't read this sentence.

Hipoy
Hipoy
  • Member since: Mar. 22, 2006
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Action Script Help? 2007-06-23 22:21:07 Reply

At 6/23/07 10:16 PM, Doritos3440 wrote: Hmm.. ok.. i suck at action script and would like something like this working:
When key (the key i want to be pressed) is pressed, go to bla bla bla!
When key (The key that was pressed) as been released, go to bla bla bla!

Could sum1 help me? plz? if not just dont reply.. no need to tell me i suck or stuff like that..

if(Key.isDown(Keycode)){
action;
} else {
action;
}

Might work, but i'm pretty shitty AS myself - give it a try

chubbs153
chubbs153
  • Member since: Aug. 9, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Action Script Help? 2007-06-23 22:24:48 Reply

on (press) {
gotoAndStop (that one frame)
}

on (release) {
gotoandStop (that one other frame)
}

if its a click button.

chubbs153
chubbs153
  • Member since: Aug. 9, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Action Script Help? 2007-06-23 22:26:27 Reply

o i didnt read the full thing, umm ya just listen too what they said i was talking about something else.

Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Action Script Help? 2007-06-23 22:43:10 Reply

im trying to make a game.. and i made a movie clip with all the hero move.. and i made the starting animation of the hero and after it on "doing nothing" with action script stop(); and i wanted to make it so when sum1 press like.. "A" it go to the part of the action where it attack.. dont know if you understand..

Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Action Script Help? 2007-06-23 22:44:31 Reply

At 6/23/07 10:20 PM, ChilliDog wrote: What do you mean "go to blah blah blah"
What do you want to happen when those Keys are pressed?
An object moves? It goes to a different part of your movie?
Noo idea what you're trying to accomplish.
Also, might I suggest looking here first AS: Main

(forgot to put the guys post at top of my last reply..)
im trying to make a game.. and i made a movie clip with all the hero move.. and i made the starting animation of the hero and after it on "doing nothing" with action script stop(); and i wanted to make it so when sum1 press like.. "A" it go to the part of the action where it attack.. dont know if you understand..

Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Action Script Help? 2007-06-23 23:02:18 Reply

Hmm.. i tried to use the action script that you guys said but.. im having some trouble making them working.. look.. my Action Script Skillz Level are lik to.. "As good as a Blind Retarded Kids".. geez.. i would rly like to make that game!

ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Action Script Help? 2007-06-23 23:23:22 Reply

Alrighty then, let's try this for your character.

onClipEvent (enterFrame) {
if (Key.isDown(65)) {
this.gotoAndPlay("attack");
}

So, when you press the A button (65) your character movie clip will play the attack animation.
And add this...

onClipEvent (keyUp) {
this.gotoAndStop("standing");
}

so that when you let go of the A button the animation will stop.
This is just one, simple way of doing this.

Also, make sure that your attack animation loops so like if the beginning frame of the attack animation is labeled "attack" then, on the last frame of the animation put this code

gotoAndPlay("attack");

So it will loop until told to do otherwise.
Good luck! Hope this helps, post any questions here or PM me or w/e.


AS: Main

Don't read this sentence.

Kart-Man
Kart-Man
  • Member since: Jan. 7, 2007
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to Action Script Help? 2007-06-23 23:24:05 Reply

At 6/23/07 10:44 PM, Doritos3440 wrote: i wanted to make it so when sum1 press like.. "A" it go to the part of the action where it attack.. dont know if you understand..

Just make a movie clip that contains two frames, one with your character standing and one with your character attacking. Then, just use the code I had written earlier:

onClipEvent (enterFrame) {
if (Key.isDown (65)) {
//because Flash doesn't recognize 'Key.A', you must use Flash keycodes instead.
gotoAndPlay (attackingframe);
}else{
gotoAndPlay (standingframe;
}
}

Look here for the rest of the keycodes you can use.


postcount +=1;
Newgrounds Photoshop Headquarters || Don't use MS Paint! Use Aviary!
SING US A SING YOU'RE THE PIANO MAN

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Action Script Help? 2007-06-23 23:32:55 Reply

Or you can save time and use this: http://img257.imageshack.us/my.php?image=keyg etter0mh.swf

Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Action Script Help? 2007-06-23 23:39:04 Reply

At 6/23/07 11:32 PM, Diki wrote: Or you can save time and use this: http://img257.imageshack.us/my.php?image=keyg etter0mh.swf

I cant see it..

ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Action Script Help? 2007-06-23 23:47:34 Reply

At 6/23/07 11:32 PM, Diki wrote: Or you can save time and use this: http://img257.imageshack.us/my.php?image=keyg etter0mh.swf

Hey that's pretty cool, thanks it will definitely come in handy.
If you couldn't see it it was a program that shows the number for whatever key you press like a-65 and such. Very handy.


AS: Main

Don't read this sentence.

Doritos3440
Doritos3440
  • Member since: Jan. 21, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Action Script Help? 2007-06-24 15:52:46 Reply

hmm.. well.. still got difficutly making it work.. -_-