00:00
00:00
Newgrounds Background Image Theme

mihaithecool 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!

Actionscript codes here!

390,074 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2004-08-13 20:56:04


onClipEvent(enterFrame){
if (Key.isDown(65)) {
if(_root.moving=="right") {
if(_root.moving_2=="left")
_root.circle.gotoAndStop(7)
} else {
_root.circle.gotoAndStop(8)
}
}
if(_root.moving=="left") {
_root.circle.gotoAndStop(8)
}

}

help its screwed

Response to Actionscript codes here! 2004-08-13 21:06:11


At 8/13/04 07:48 PM, PunkerFish wrote: How would I make it so if you're touching the open door and press up, it goes to the next frame?

Try puttin this on the open door:

onClipEvent (enterFrame) {
if (_root.player.hittest(this) && Key.isDown(Key.UP)) {
// Stuff Happens
}
}

Change _root.player to whatever your guy's instance name is..

Response to Actionscript codes here! 2004-08-13 21:20:27


At 8/13/04 08:34 PM, RedCircle9 wrote:
At 8/13/04 08:15 PM, HAM_Mosessess wrote: Okay, I don't know if this question has been asnwered before, But I don't Think even YOU would go through 150 pages.
Who is "YOU"???

Stuff
The line below this reply has it starting out with a "}"...why?

}onClipEvent(mouseUp) {if(_root.currentammo>0) {gotoandPlay(_root.gun}{frame=1); _root.currentammo-=1}}
}if(Key.isDown(Key.SPACE)) {if(_root.ammoclips>0) {gotoandPlay(_root.gun}(frame=3}}

yeah well, if I remove it, I get two more errors stating that i NEED it there than I need to remove a "}" in THIS script! here is the errors:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 17: ')' or ',' expected
onClipEvent(mouseUp) {if(_root.currentammo>0) {gotoandPlay(_root.gun}{frame=1); _root.currentammo-=1}}

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 18: Unexpected '}' encountered
}if(Key.isDown(Key.SPACE)) {if(_root.ammoclips>0) {gotoandPlay(_root.gun}(frame=3}}

Total ActionScript Errors: 2 Reported Errors: 2

Response to Actionscript codes here! 2004-08-13 21:41:07


I am in need of a special code that relates with time. See what im trying to do is basicly trying to make a flash that changes the the background of it according to day. Basicly i want a script thats like a clock. For example i want to make it so if you look at the flash at night time the background on the flash will be night time but if you go in during day time its sunny and day time. And i would also want perhaps a few days where its randomly raining or something like that. So if anyone can help me please do!

-Pako-


OMG THATLOL!!

Response to Actionscript codes here! 2004-08-13 22:06:44


At 8/13/04 09:20 PM, HAM_Mosessess wrote: yeah well, if I remove it, I get two more errors stating that i NEED it there than I need to remove a "}" in THIS script!

Ok...let me sort your code out...and make it look legible at the same time:

onClipEvent (enterFrame) {
this._x = _root._xmouse += 20;
} //So far fine
onClipEvent (mouseDown) {
shot += 1;
} //fine
onClipEvent (enterFrame) {
if (shot>0) {
{"_root.gun"} { //howabout _root.gun.play();
play();
}
}
}
onClipEvent (mouseUp){
shot=0;
} //fine
}
onClipEvent(mouseUp) {
if(_root.currentammo>0) {
gotoandPlay(_root.gun //_root.gun.gotoAndPlay(1);
}
{frame=1); //what is going on here?
_root.currentammo-=1 //no semicolon
}
}
}
if(Key.isDown(Key.SPACE)){
if(_root.ammoclips>0) {
gotoandPlay(_root.gun //_root.gun.gotoAndPlay(3);
}
(frame=3
}
}

I haven't changed anything. I just spaced it out. What are you doing with all those extra "}" and ")"???

Also, if this code is in the gun MC, then you can use "this" instead of "_root.gun"

Response to Actionscript codes here! 2004-08-14 01:50:38


with the duplliate movie clip function, if I want to be using it more than once... such as a movie with this code: (I know this is flawed)

onClipEvent (load) {
this._x += (random(360));
count = 0;
}
onClipEvent (enterFrame) {
count++;
if (count == 120) {
duplicateMovieClip(this, 'block'+(this._x), 100);
_root.'block'+(this._x)._y = -42;
_root.'block'+(this._x).count = 0;
}
this._y++;
}

what I wanted it to do was start falling, and when the counter reached 120, have it duplicate itself (at the top), and have that duplicate start falling, and duplicate itself also.

I wasn't sure how to refer to the instance name of the movie clip if I wanted it to be different for each new one... How should I have done this?

Response to Actionscript codes here! 2004-08-14 05:17:53


Anyone has a ladder Script?? like when you are on the ladder u press up and the player Climbs up?

Response to Actionscript codes here! 2004-08-14 05:51:21


At 8/14/04 05:17 AM, Awwe wrote: Anyone has a ladder Script?? like when you are on the ladder u press up and the player Climbs up?

like from a side view?
if so, you can do it like this, I guess:
on(enterFrame){
//motion code
if(KEY.isDown(Key.UP)){
if(this.hitTest(ladder)){
this._y -= speed;
}
}
}

that code makes it so that if you press up, AND if you're touching the ladder, it'll go up. You'd need to code in some gravity simulating thing, too, so that if you stepped off of the ladder after climbing partway up, you'd fall down to the ground. Hope this helps.

Can anybody answer my question? (one post up)

Response to Actionscript codes here! 2004-08-14 08:29:42


can anybody help me here?

i have a platform game and i got all the movements and jumping good, but i need to know how to make him looklike his moving his legs... right now all his doing is.. like doing some sort of moonwalk lol.

k this is what im using:

onClipEvent (enterFrame) {
if (Key.isDown(37)) {
this._x -= speed;
this.gotoAndPlay(3);
lastDir = "left";
}

but when i gotoAndPlay(3) it just takes one step and stays like it while im holding down the direction key.

Response to Actionscript codes here! 2004-08-14 08:33:55


At 8/14/04 08:29 AM, powerman50001 wrote:
but when i gotoAndPlay(3) it just takes one step and stays like it while im holding down the direction key.

Well, what is at frame 3? What it should be is a movie clip (inside the movie clip that you're controlling) that has a loop of the walking animation. Also, you can use gotoAndStop(3) instead, so it stays there... and then, when you release it, it reverts to the standing frame.

Response to Actionscript codes here! 2004-08-14 10:33:02


I'm going to clarify my question:

Say this is in a 550x400 stage...

onClipEvent(load){
this._y = 0;
this._x = random(550);
count = 0;
}
onClipEvent(enterFrame){
if(count <= 120){
count++;
}
this._y += 3;
if(count == 120){
//duplicate this movie clip, so that it will (because of the on(load) thing) be at a random x position at the top of the screen, and so that it will start falling also... and so that after 120 frames, it'll make a duplicate also so that these things will continue to fall from random positions at the top every 120 frames. The only trouble I'm having with this is that I don't know how to phrase the duplicateMovieClip function so that it can be used more than once (so that the instance name of the new movie clip will be different for each new one.) And another thing I'd like to know about this is how would I refer to these instances?
}
}

Response to Actionscript codes here! 2004-08-14 10:55:37


I've got a question: i'm making a game where you control a mc with your mouse. But i want it to move left/right when you move your lmouse left/right, and not up and down, kind of like the way you create a mouse controlled paddle in a breakout kind of game. I could also make it so that you move it with the arrow buttons, but i want to make a fast game. The arrow buttons are way too slow to follow the game pace...

Response to Actionscript codes here! 2004-08-14 11:00:15


Never mind: i experimented and found it !
I'm starting getting the hang of AS :)

Response to Actionscript codes here! 2004-08-14 11:08:22


how do you make a loading status menu for a flash movie?

Response to Actionscript codes here! 2004-08-14 11:39:05


how do i make a count down starting at 1 minute going by tenths of seconds

Response to Actionscript codes here! 2004-08-14 11:52:43


I have tried many different codes for my Side Scrolling beat 'em up. Some found on the Fighting game thread, and some on this one, but none have worked. I have my player movie clip with 5 frames:
1- Standing
2- Right
3- Punch
4- Jump
How do i make it so when i press:
RIGHT it goes to Frame 2
CONTROL it goes to Frame 3
UP it goes to Frame 4.
Upto now i have:
onClipEvent (load) {
moveSpeed = 5;
punch = false;
jump = false;
this.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
this.gotoAndStop(2);
}
if (Key.isDown(Key.CONTROL) && (punch == false)) {
punch = true;
this.gotoAndStop(3);
}
if (Key.isDown(Key.UP) && (jump == false)) {
jump = true;
this.gotoAndStop(4);
}
if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.CONTROL) && !Key.isDown(Key.UP) && (jump == false) && (punch == false)) {
this.gotoAndStop(1);
}
}

But this replays each of the animations when i press the button. E.g when i press jump he doesn't stop jumping. Can somebody please fix this code.
Thanks!!

Response to Actionscript codes here! 2004-08-14 20:45:45


At 8/13/04 09:06 PM, Mitch-Mac wrote: Try puttin this on the open door:

Thanks Mitch-Mac.

Another question though. If the character MC touches the fire MC, it tell is to go to the second frame in the character MC where it has another MC with an animation of him burning. At the end of this animation it says:

_root.lives = _root.lives -1;
_root.prevFrame;

That tells it to take away a life and start at the begin level frame. The problem is that while the fire touches you, it keeps sending you to the 2nd frame and it won't play the animation. Is there any way to have the MC disregard the hitTest while it's playing?

I can email the fla to you but I use MX 2004.

Response to Actionscript codes here! 2004-08-14 20:55:46


At 8/14/04 11:08 AM, sebsebm wrote: how do you make a loading status menu for a flash movie?

You mean a preLoader? You can go to page 147 on this thread and look towards the bottom for a post by Deathon7 that starts with 'How to Make a Preloader, by Deathcon7'.

Response to Actionscript codes here! 2004-08-14 22:24:52


can someone explain hittest? please.

how do i make my player kill a enemy?

Response to Actionscript codes here! 2004-08-14 22:28:25


At 8/14/04 10:24 PM, skyburner wrote: can someone explain hittest? please.

how do i make my player kill a enemy?

put this code onto the enemy:

if(this.hitTest(player)){
this.gotoAndStop(deathsequence);
}

What this does is, whenever the enemy touches the player, it'll die (deathsequence would be the frame inside its movieclip where it shows an animation of him dying.) But if you want to have bullets or anything, that's a different story.

Response to Actionscript codes here! 2004-08-14 22:33:24


*Error** Scene=Scene 1, layer=Layer 2, frame=3:Line 1: ')' expected
if(this.hitTest(hero)weapon){

Response to Actionscript codes here! 2004-08-14 22:40:05


At 8/14/04 10:33 PM, skyburner wrote: *Error** Scene=Scene 1, layer=Layer 2, frame=3:Line 1: ')' expected
if(this.hitTest(hero)weapon){

sorry im stupid-onClipEvent (load) {if(this.hitTest(hero)){
this.gotoAndStop(deathsequence);
}
}

but it just stays there when my player hits it.

Response to Actionscript codes here! 2004-08-14 22:45:00


At 8/14/04 10:40 PM, skyburner wrote:
At 8/14/04 10:33 PM, skyburner wrote: *Error** Scene=Scene 1, layer=Layer 2, frame=3:Line 1: ')' expected
if(this.hitTest(hero)weapon){
sorry im stupid-onClipEvent (load) {if(this.hitTest(hero)){
this.gotoAndStop(deathsequence);
}
}

but it just stays there when my player hits it.

onClipEvent(enterFrame) not onClipEvent(load)
and you might need _root.hero


BBS Signature

Response to Actionscript codes here! 2004-08-14 22:46:44


sorry to double post, but i didnt see the other thing you posted. it should be:

_root.hero.weapon

not

(hero)weapon


BBS Signature

Response to Actionscript codes here! 2004-08-14 22:55:45


can you show me the full code? please i still dont understand.
sorry.

Response to Actionscript codes here! 2004-08-14 23:11:17


At 8/14/04 10:55 PM, skyburner wrote: can you show me the full code? please i still dont understand.
sorry.

never mind i got.

Response to Actionscript codes here! 2004-08-15 00:29:51


sorry for the late replies, I had to ride a hurricane through so I couldn't really go on the pc, lol

At 8/13/04 02:47 PM, PunkerFish wrote:
At 8/13/04 10:20 AM, Deathcon7 wrote: Woah, not that difficult. All you have to do is put a couple buttons, have lots of MC with the different variations. It'll be simple. I would like to see how the site does it tho, cause that link doesn't work.
Sounds hard to me. Can you give an example?

Okay, for example, you want to make a custumizable head, you would have a left and right button, on the right button you would put:

on(release){
_root.headMC.nextFrame();
}

and then on the left arrow you would put:

on(release){
_root.headMC.prevFrame();
}

Then, on the head MC, make like 5 frames with different variations. The buttons will then scroll through the MC. Then, have a frame that evaluates a variable. For example, frame 3 makes the head variable equal 3. Then when you evaluate the customized head stays on Frame 3. Is that a bit more clear?

At 8/14/04 11:08 AM, sebsebm wrote: how do you make a loading status menu for a flash movie?

A preloader? Try d/ling the NG one. There's a link on the portal.

At 8/14/04 11:39 AM, SERVAA wrote: how do i make a count down starting at 1 minute going by tenths of seconds

Put this on the frame. Basically what it does is it counts down by seconds from a minute. I don't know what you mean by 1/10ths so i'll just let you modify later.

onLoad = function () {
multiplier = 12;
minutes = 1;
countDown = (60*multiplier)*minutes;
};
onEnterFrame = function () {
--countDown;
if (countDown<=0) {
trace("Count Down Expired");
}
};

Response to Actionscript codes here! 2004-08-15 00:52:03


Why don't my hittests work if I copy the MC?

On my character I have a hittest that says if he touches the fire MC to kill him. But only one of the fire MCs kills him and if I copy the MC, it won't kill him. What's wrong?

Response to Actionscript codes here! 2004-08-15 01:18:45


each new 'fire mc' you have should have a different instance name, and the player only responds to the first one. What you can do about this is put the hitTest code on the fire mc to be duplicated instead of on the player, so that you can say
if(this.hitTest(_root.player)){
//death sequence
}

And no matter what the instance name the fire has at that point, it'll work.

(Can anybody answer my question?)

Response to Actionscript codes here! 2004-08-15 01:44:06


Im El Newb (not that any1 cares, lol) but, yeah i been dabbiling in flash for a bit now, but i cant seem to get the hang of action script. I'd like to know how all u gurus out there learned jus what the hell u were doing in general. Where is a good place to start?