00:00
00:00
Newgrounds Background Image Theme

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

389,763 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2003-12-26 07:00:48


At 12/25/03 08:55 PM, dirtybuzzin wrote: i dont know anything about action scripting :( can you give me a link you a site that explanes in plain english action scripts, an not flashkit .

try this:

www.actionscript.org

Or go to a local book store and buy an actionscript book.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 07:04:18


any questions


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 09:09:55


I asked my question before, the one about cars and that. If that is onsolvable then just tell me.

Response to Actionscript codes here! 2003-12-26 09:22:14


At 12/26/03 09:09 AM, mexxa wrote: I asked my question before, the one about cars and that. If that is onsolvable then just tell me.

You mean that car thinghy about facing the road explain the prob again please... I didn't really get what you mean but its solvable, im sure of that!


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:02:39


You controle a car and the compuyer makes a car folow you but the following car has to face the right way acording to the street.

Response to Actionscript codes here! 2003-12-26 11:05:34


At 12/26/03 11:02 AM, mexxa wrote: You controle a car and the compuyer makes a car folow you but the following car has to face the right way acording to the street.

So if there is a corner the direction of the car chasing you changes? is that correct?


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:11:12


ye but this is were i find it hard to do because if there is a four way junction the enemy car would look weird if it suddenley changed direction when all the other cars run smoothly.

Response to Actionscript codes here! 2003-12-26 11:14:21


At 12/26/03 11:11 AM, mexxa wrote: ye but this is were i find it hard to do because if there is a four way junction the enemy car would look weird if it suddenley changed direction when all the other cars run smoothly.

im working on a code for you but it is kinda hard but it is possible and I know I can do it


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:15:47


You get credit for this

Response to Actionscript codes here! 2003-12-26 11:25:48


At 12/26/03 11:15 AM, mexxa wrote: You get credit for this

Im not done with the code yet but I have An idea how I'm gonna solve this.

The first step is to label the car that chases you 'CAR'
and the player's car 'PLAYER'

Put this script in the player car:


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<15) {
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 this in the car that chases you.


onClipEvent (enterFrame) {
clipToFace = _root.player;
xdiff = clipToFace._x-_x;
ydiff = clipToFace._y-_y;
offset = 0;
}
onClipEvent (enterFrame) {
this._y += ydiff/15;
this._x += xdiff/15;
}

That would have the movement and following done, only the corner script... its coming up!


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:27:39


Oh yes forgot to post:

Make a new movieclip, with a corner drawn inside it. You are going to use this movieclip for EVERY CORNER


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:35:19


Sorry if you used this on the car but this is the car script i se for my normal car.

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<40) {
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;
}

Response to Actionscript codes here! 2003-12-26 11:45:05


Im sorry Mexxa I am almost there but I got somthing moere important to do:

DINNER

I will be back as soon as I can


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 11:54:22


Okay i got It done but I cant explain it, so I will have to send you a FLA file, but you got your email adress invisible, so you'll have to mail me


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 12:04:08


my email is united_idiots@hotmail.com but dont try anything on msn.

Response to Actionscript codes here! 2003-12-26 12:40:01


Ok i mailed the fla to you, but it still is crappy and you're not gonna b satisfied with it. Neither am I but I never use the car script myself so I dont think I can help u further. I recommend you talk to Tom of The Super Flash Bros

(flashbros@hotmail.com)


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-26 13:25:48


hi, i wont to make one of those games were something is droping from the sky an you use the mouse which will be a hand or somthing you catch the falling things. if you dont know what i mean here is the type of game i wont to make http://www.newgrounds.com/portal/view.php?id=142000 can somone helo me plz

Response to Actionscript codes here! 2003-12-26 13:52:28


Evil Ludy: you know the idea for the turning script would it be possible to make a specific point (place along the x axis) wich if the enemy got to it copied the movie clip, moved it and rotated it slightly then deleted the original clip until the enemy faced a specific direction then it stop that bit and carried on chasing.

Response to Actionscript codes here! 2003-12-26 16:10:53


here's a script i made that creates random straight lines from the top of the screen and random x origons. also, the colors are random. put this script in the frame.

colour = random(0xFFFFFF);
xi = 10;
c = random(550);
m = Math.random()*10;
_root.onEnterFrame = function() {
x += xi;
y = m*x;
_root.createEmptyMovieClip("line", 1);
with ("line") {
lineStyle(1, colour, 100);
moveTo(x+c, y);
lineTo(x-xi+c, (x-xi)*m);
}
if (x+c>550 || y>400) {
x = 0;
m = Math.random()*7;
c = random(550);
colour = random(0xFFFFFF);
}
};

Response to Actionscript codes here! 2003-12-26 16:13:18


heh, here's a little alteration to the script i just posted... now it has a random x and y origon.

colour = random(0xFFFFFF);
xi = 10;
b = random(400);
c = random(550);
m = Math.random()*10;
_root.onEnterFrame = function() {
x += xi;
y = (m*x)+b;
_root.createEmptyMovieClip("line", 1);
with ("line") {
lineStyle(1, colour, 100);
moveTo(x+c, y);
lineTo(x-xi+c, (x-xi)*m+b);
}
if (x+c>550 || y>400) {
x = 0;
b = random(400);
m = Math.random()*7;
c = random(550);
colour = random(0xFFFFFF);
}
};

Response to Actionscript codes here! 2003-12-26 16:47:06


Mexxa, is this what you're asking for, regarding the enemy chasing the player?:

onClipEvent (load) {
speed = 10;
}
onClipEvent (enterFrame) {
if (!this.hitTest(_root.player._x, _root.player._y, true)) {
angle = Math.atan2(_root.player._y - _y, _root.player._x - _x);
xg = Math.cos(angle) * speed;
yg = Math.sin(angle) * speed;
_x += xg;
_y += yg;
_rotation = angle / (Math.PI / 180);
}
}

Response to Actionscript codes here! 2003-12-26 23:19:39


Something easy but edittable to beginners. It's hard to get more basic then this so don't think i've put this up for how good, but for how easy it is.

On the first frame add this to the actionscript:

_root.moveTo(_root._xmouse, _root._ymouse);

On the second frame place this actionscript there:

_root.lineStyle(5, 0xAABBCC);
_root.lineTo(_root._xmouse, _root._ymouse);

Then lastly on the third and final frame put:

gotoAndPlay(2);

Try playing around with the numbers in frame 2 to suit what you want, just move the mouse around.

Now, something else i made but it's harder to understand for beginners.

Set the board dimensions as 400 x 400.
The frame rate should be 100 for a nice, fast and smooth action.

Make a blank movie clip and place this in the middle of the board give it an instance of "crosshairs".

Next make another blank movie clip and give it an instance name of "controller" if you want. Place it down anywhere then align it's y position to the middle with ctrl + k, then press ctrl + i and put it's x position as 300( middle of the board plus 100 which is the radius in the following code ). Now add the following to it's actions:

onClipEvent (load) {
radius = 100;
degrees = 0;
_root.lineStyle(1, 0xFF9900, 100);
_root.moveTo(this._x, this._y);
}
onClipEvent (enterFrame) {
_root.lineTo(this._x, this._y);
angle = degrees*(Math.PI/180);
degrees = degrees+2;
xposition = radius*Math.cos(angle);
yposition = radius*Math.sin(angle);
this._x=xposition+_root.crosshairs._x;
this._y=yposition+_root.crosshairs._y;
}

Response to Actionscript codes here! 2003-12-27 02:10:45


First of all, go binary.
secondly, i need a script for when my character, nate, runs into the remote, it plays the scene entitled clipscene1.
How do i so this?!
When i tried hittest, my remote dissapeared. I am frustrated and more confused than i thought to be possible.
can someone help me?

Response to Actionscript codes here! 2003-12-27 02:21:09


At 12/27/03 02:10 AM, pac-man10 wrote: When i tried hittest, my remote dissapeared.

now it is there, but my guy stands ontop of it istead of runing into it.

Response to Actionscript codes here! 2003-12-27 02:44:03


now it's just going through it!

this is what i have on the remote:

onClipEvent (enterFrame) {
if (this.hitTest(_root.nate)) {
true;
gotoAndPlay("cutscene1", 1);
}
}

Please help me

Response to Actionscript codes here! 2003-12-27 05:40:30


What do you mean? remote?


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-27 09:59:27


Hey evilludy I bought this book on AS but it's not really helping me out,it tells you how to use AS for movies,I want to know how to do it for games,I tried gettign the book you have but they don't sell it anymore so how else can I learn actionscripting?I dont' want it handed out to me,I want to know what it all means.

Response to Actionscript codes here! 2003-12-27 10:22:42


At 12/27/03 09:59 AM, Nova_dragon wrote: Hey evilludy I bought this book on AS but it's not really helping me out,it tells you how to use AS for movies,I want to know how to do it for games,I tried gettign the book you have but they don't sell it anymore so how else can I learn actionscripting?I dont' want it handed out to me,I want to know what it all means.

The book I got is only for sale in hollad and I don't know any books in other languages.

I can give you some advice:
Go to this web page, there are 139 Tutorials in there and every single detail is explained.

And there is also a (very expansive) flash book I know that is translated in a lot of languages, the FLASH MX ACTIONSCRIPT BIBLE

If you plan to buy that, be sure you buy the Actionscript Bible and not the Flash Bible.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-12-27 11:30:13


do u no how to put in double guns or diving ?

Response to Actionscript codes here! 2003-12-27 11:41:40


Thanks for the help