00:00
00:00
Newgrounds Background Image Theme

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

393,027 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2003-12-15 17:01:34


Ok, to keep a long story short, evilludy, can you help me out with a game I'm making? I have a group and all, just need a good programmer(you have the book, so you're probably good). the game's info is on my site and there's a BBS link there(click on the madness-like guys) to where i started it in here. :)


I'm back!

Sanity is grossly overrated and detrimental to the creative process.

SoundCloud - Bandcamp

Response to Actionscript codes here! 2003-12-16 01:59:00


How you make this script so when it plays it plays a MC

onClipEvent (load) {speed = 5;}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) _x += speed; else if (Key.isDown(Key.LEFT)) _x -= speed;
}

and flips when you push left around. Push how could you make the speed have a variable number

Response to Actionscript codes here! 2003-12-16 13:19:46


I need to know if there's a property or object to refer to the movieclip having called a function...
this is cause I define a _global function , and need to refer to the calling movie clip without knowing which one it is...( will be used in LOTS of different clips... so I want to know if there's some way to refer to it or at least to simulate a reference to it.

thx to anybody who tries to help :P

Response to Actionscript codes here! 2003-12-17 01:50:08


that doesnt help

Response to Actionscript codes here! 2003-12-17 14:45:27


k could you help me say i want to make a game like snake i need snake to die when it goes of the screen how do i do that

Response to Actionscript codes here! 2003-12-17 15:54:00


At 12/17/03 02:45 PM, yasowhat wrote: k could you help me say i want to make a game like snake i need snake to die when it goes of the screen how do i do that

well, there are a few ways to do this, i will explain 3 of them for you;

(1) : Lines

Draw a line, it doesn't hav to be a thick one, then convert it to an MC. Then change the instance name of the line to "wall" (it doesn't have to be wall, this is just for this example). Then add this code to the snake

onClipEvent(enterFrame){
if (this.hitTest(_root.wall))
this.gotoAndPlay"snake die" //this is only if you have a snake die frame
}

the lines can be put anywhere on the screen, so any obsticles can be made in the same way.

also, so that the lines cannot be seen, add this code to the line:

onClipEvent(enterFrame){
this._visible = false
}

(2): A box

Draw a box that covers the entire stage, then covert it to an MC, one again, we need to give it an instance name, for this example i will call it "box";
now add the following code to the snake;

onClipEvent(enterFrame){
if(!this.hitTest(_root.box)) // the ! makes it mean if it doesn't
this.gotoAndPlay "snake die" //this is only if you have a snake die frame
}

once again, we dont want this to be seen, so use;

onClipEvent(enterFrame){
this._visible = false
}

(3) : x,y coordinates

This one is probobly the most complicated of them all to use as you use the x,y coordinates of the stage to see if the snake will die or not.
the following code will need to be inputed in the the actions of the snake MC;

onClipEvent(enterFrame){
if (this._x>a){ //a = stage width
this.gotoAndPlay"snake die"
} else if(this._x<0){
this.gotoAndPlay "snake die"
} else if(this._y>b){ //b = stage height
this.gotoAndPlay"snake die"
} else if(this._y<0){
this.gotoAndPlay "snake die"
}
}

there you have it, obviously you dont need to use all three scripts,just pick the one that you think will bennefit you the most, and use it.

-Dan

Response to Actionscript codes here! 2003-12-17 22:32:53


i have a movie clip named snow, and i want a button that deleates the snow when i touch it, so far this is what i have and it aint workin

onClipEvent (mouseUp){
removeMovieClip(snow);
}

Response to Actionscript codes here! 2003-12-18 00:31:52


At 12/17/03 10:32 PM, death_recon wrote: i have a movie clip named snow, and i want a button that deleates the snow when i touch it, so far this is what i have and it aint workin

onClipEvent (mouseUp){
removeMovieClip(snow);
}

shouldnt it be mouseover if you want it to go away when the clicker touches it? or if you want it to be deleted when you click it, it should be mousedown....correct me if i'm wrong but i dont think i am.

Response to Actionscript codes here! 2003-12-18 14:06:55


hey...is there anyway to make a gif move...like how do you make it look like someone's walking across the screen...or do i actually have to animate every leg movement

Response to Actionscript codes here! 2003-12-19 00:42:46


At 12/18/03 02:06 PM, Drumminjay wrote: hey...is there anyway to make a gif move...like how do you make it look like someone's walking across the screen...or do i actually have to animate every leg movement

IM not sure wot u meen by gif move
do u meen like a imported picture?

btw
THIS TOPIC IS DYYYIN!!!

Response to Actionscript codes here! 2003-12-19 04:53:37


could someone help me:
i use a code i found on this post
here it is:

onClipEvent (load) {
// Choose a movespeed
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)) {
} else {
this._x += moveSpeed;
}
// Move Right
} else if (Key.isDown(Key.UP)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true)) {
} else {
this._y -= moveSpeed;
}
// Move Up
} else if (Key.isDown(Key.DOWN)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true)) {
} else {
this._y += moveSpeed;
}
// Move Down
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true)) {
} else {
this._x -= moveSpeed;
}
// Move Left
}
}
onClipEvent (enterFrame) {
if (_root.player._x > 500) {
this._x -= 10;
tellTarget ("_root.walls") {
_x -= 10;
}
}
if (_root.player._x < 50) {
this._x += 10;
tellTarget ("_root.walls") {
_x += 10;
}
}
if (_root.player._y > 350) {
this._y -= 10;
tellTarget ("_root.walls") {
_y -= 10;
}
}
if (_root.player._y < 50) {
this._y += 10;
tellTarget ("_root.walls") {
_y += 10;
}
}
}

ok, this code works, but when i make a copy of the mc 'Walls' the copy dosent work (e.g. the 'character' isnt stoped by the wall :'( )
PLEASE help me......... please?
Mush(taq)

Response to Actionscript codes here! 2003-12-19 07:25:22


i think the best thing to do is copy all the script with walls in it and then make anova MC but cal it boundry or somthing and add the code to that but replace the walls with boundry but im not sure there would be a hell easy way but i do things the long way

Response to Actionscript codes here! 2003-12-19 11:14:54


At 12/19/03 12:42 AM, BroADfooT wrote:
At 12/18/03 02:06 PM, Drumminjay wrote: hey...is there anyway to make a gif move...like how do you make it look like someone's walking across the screen...or do i actually have to animate every leg movement
IM not sure wot u meen by gif move
do u meen like a imported picture?

btw
THIS TOPIC IS DYYYIN!!!

a gif is like an animated picture...like just a three frame picture...like someone walking or something like that

Response to Actionscript codes here! 2003-12-19 22:35:18


At 12/17/03 10:32 PM, death_recon wrote: i have a movie clip named snow, and i want a button that deleates the snow when i touch it, so far this is what i have and it aint workin

onClipEvent (mouseUp){
removeMovieClip(snow);
}

Try this:

onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) removeMovieClip(this);
}

Hehe... everything in that script is a keyword.

Response to Actionscript codes here! 2003-12-20 08:11:07


Ok. I'm back at the bbs for a moment, Ask me loads of stuff and give me an oppertunity to post a lot so i will stay


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-20 14:57:50


At 12/20/03 08:11 AM, eviLudy wrote: Ok. I'm back at the bbs for a moment, Ask me loads of stuff and give me an oppertunity to post a lot so i will stay

You shouldnt have asked. I have a car script i nicked so i dont know it. I was wondering how would i create one that had the mph or kph for the vechiles involved in a crash so that it went to certain frame when they hit (depending on how fast each other were traveling) adn for none moving objects i could define the strenth in each way. If i challenged myself i might be able to do this, but the i would be at a loss on how to make it so that it rounds the number(speed) to the nearest ten ;so that the file size is less( without this code there would have to be a frame for every speed).

Response to Actionscript codes here! 2003-12-20 18:17:42


k evilludy i need a wall script for this game, but movement is not like tradional rpgs its like driving a car. i got the script from the first page of this thread somewhere..
is there a way to make it so that as soon as one mc hits another at a certain side (left right) it can't go any further toward that side? (without using code that would make me have to find the x and y boundaries manually for every wall)
thx in advance

Response to Actionscript codes here! 2003-12-20 19:12:19


I'm having trouble for the Action Script for movement. I can get my object to move using the Righ, left, up down keys but I want to use keys like A, D, E etc. But I'm having trouble doingso. Any help?

Response to Actionscript codes here! 2003-12-21 00:43:31


here ludy, in case you didnt check the lounge

Actionscript codes here!

Response to Actionscript codes here! 2003-12-21 00:53:12


here ludy, in case you didnt see that lounge

Actionscript codes here!

Response to Actionscript codes here! 2003-12-21 04:54:07


oops ,i hate that

Actionscript codes here!

Response to Actionscript codes here! 2003-12-21 05:10:11


Put this on a blank frame:

this.onMouseMove = function() {
this.createEmptyMovieClip("ln" + ++d, d);
with (this["ln" + d]) {
lineStyle(1, 0x000000, 85);
moveTo(lx, ly);
lx = _root._xmouse;
ly = _root._ymouse;
lineTo(lx, ly);
this["ln" + d].onEnterFrame = function() {
_alpha -= 10;
if (_alpha < 0) {
delete this.onEnterFrame;
removeMovieClip(this);
}
};
}
updateAfterEvent();
};

Enjoy! :)

Response to Actionscript codes here! 2003-12-21 06:36:31


At 12/20/03 06:17 PM, alphastrike wrote: k evilludy i need a wall script for this game, but movement is not like tradional rpgs its like driving a car. i got the script from the first page of this thread somewhere..
is there a way to make it so that as soon as one mc hits another at a certain side (left right) it can't go any further toward that side? (without using code that would make me have to find the x and y boundaries manually for every wall)
thx in advance

So this is the script u used...

onClipEvent (enterFrame) {
// right
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
// left
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
// up
if (Key.isDown(Key.UP)) {
if (move<8) {
move++;
}
} else if (move>0) {
move--;
}
// down
if (Key.isDown(Key.DOWN)) {
if (move>-10) {
move--;
}
} else if (move<0) {
move++;
}
// enter
if (Key.isDown(Key.ENTER)) {
_x = 200;
_y = 200;
_rotation = 0;
move = 0;
}
// _x & _y position
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}

So what you do is...

1. You draw the walls
2. You put ALL walls in a movieclip
3. Give that movieclip the instance name WALLS
4. Change the script in the player/car movieclip into:


onClipEvent (enterFrame) {
// right
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
// left
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
// up
if (Key.isDown(Key.UP)) {
if (this.hitTest(_root.walls)) {
} else {
if (move<8) {
move++;
} else if (move>0) {
move--;
}
}
}
// down
if (Key.isDown(Key.DOWN)) {
if (this.hitTest(_root.walls)) {
} else {
if (move>-10) {
move--;
} else if (move<0) {
move++;
}
}
}
// enter
if (Key.isDown(Key.ENTER)) {
_x = 200;
_y = 200;
_rotation = 0;
move = 0;
}
// _x & _y position
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}

That should do the trick.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-21 06:43:41


Can you anwer my question, i aasked first here is the code:

onClipEvent (enterFrame) {
_root.speed = speed;
_root.mph = Number(speed)*99;
_root.mph -= _root.mph%1;
if (_root.mph<1) {
_root.mph = 1;
}
if (Key.isDown(Key.UP)) {
speed += 1.1;
}
if (Key.isDown(Key.DOWN)) {
speed -= 1.1;
}
if (Math.abs(speed)>90) {
speed *= .99
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 4;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 4;
}
speed *= .9999;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.boundary.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -2;
}
}
onClipEvent (enterFrame) {
if (this._x>600) {
this._x = -50;
}
}
onClipEvent (enterFrame) {
if (this._y>450) {
this._y = -50;
}
}
onClipEvent (enterFrame) {
if (this._x<-50) {
this._x = 600;
}
}
onClipEvent (enterFrame) {
if (this._y<-50) {
this._y = 450;
}
}

onClipEvent (enterFrame) {
speed *= .9
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.boundary2.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -2;
}
}

Response to Actionscript codes here! 2003-12-21 06:43:58


At 12/20/03 02:57 PM, mexxa wrote:
You shouldnt have asked. I have a car script i nicked so i dont know it. I was wondering how would i create one that had the mph or kph for the vechiles involved in a crash so that it went to certain frame when they hit (depending on how fast each other were traveling) adn for none moving objects i could define the strenth in each way. If i challenged myself i might be able to do this, but the i would be at a loss on how to make it so that it rounds the number(speed) to the nearest ten ;so that the file size is less( without this code there would have to be a frame for every speed).

Car script with MPH meter:

onClipEvent (enterFrame) {
// right
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
// left
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
// up
if (Key.isDown(Key.UP)) {
if (move<30) {
move++;
}
} else if (move>0) {
move--;
}
// down
if (Key.isDown(Key.DOWN)) {
if (move>-10) {
move--;
}
} else if (move<0) {
move++;
}
// enter
if (Key.isDown(Key.ENTER)) {
_x = 200;
_y = 200;
_rotation = 0;
move = 0;
}
// _x & _y position
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
_root.speed = move*3;
}

And put a dynamic textbox somewhere that is linked to SPEED


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-21 06:49:37


When i tried that the text never changed i'll try again. Is it possible to do the rest of the script (timesing to variables together to get the frame you should be on) forget the rounding.

Response to Actionscript codes here! 2003-12-21 07:08:37


Movement with W, H, S and D:

onClipEvent (enterFrame) {
if (Key.isDown(87)) {
this._y -= 5;
}
if (Key.isDown(83)) {
this._y += 5;
}
if (Key.isDown(65)) {
this._x -= 5;
}
if (Key.isDown(68)) {
this._x += 5;
}
}

Sorry people im leaving for 3 dayz now.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-21 07:18:48


Sorry that script did work, what would be the script for a car which you dont control and has a nearly random speed (it slows down at corners and then speeds up to a random speed).

Response to Actionscript codes here! 2003-12-21 08:41:55


What do you mean "for which you don't control"?

Response to Actionscript codes here! 2003-12-21 08:45:00


At 12/21/03 08:41 AM, Sulphent wrote: What do you mean "for which you don't control"?

A computer car not one you make turn and accelerate e.c.t.