00:00
00:00
Newgrounds Background Image Theme

GasGrass 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,047 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2003-06-19 00:13:54


At 6/18/03 06:34 AM, eviLudy wrote: Awnsering to Y3llow's question:

im doing it by looking down on the character, s all of the movement cycles will be the same. the movement code ive used makes him walk and change dirextions and turn when u press an arrow key. ill try that code but would there be a simpler one that would just make the walking cycle go, and could it be a different script in a different MC?


BBS Signature

Response to Actionscript codes here! 2003-06-19 02:03:45


At 6/18/03 10:39 PM, NinFoxwoods wrote: Im having trouble with this enemey AI progarmming can anyone help me please?

it really depends what type of AI you need. you can have easy AI or hard AI. i dont think i can do hard AI. but the easy AI would be to make it so they enemies bounce off walls and go in a certain direction or just have it go in a set direction.

Response to Actionscript codes here! 2003-06-19 09:57:22


At 6/19/03 02:03 AM, ChocolateChipClock wrote:

:-

talk the talk but no walk the walk.

Response to Actionscript codes here! 2003-06-19 11:22:18


I tried the jump AS and everything worked except for when my character lands on the ground. Basically the character goes right threw the ground MC. I named the MC ground like instructions said. How do i make the ground stop the guy?

Response to Actionscript codes here! 2003-06-19 12:56:35


go to the propperties of the ground, and tick in the textbox "label" ground.

That should do the trick, you dont have to name it ground, as long as you label it ground, because the label it the name the actionscript uses.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-19 14:04:37


At 6/19/03 09:57 AM, Idoru wrote:
At 6/19/03 02:03 AM, ChocolateChipClock wrote: -
talk the talk but no walk the walk.

which reply were you quoting?

Response to Actionscript codes here! 2003-06-19 14:17:33


thanx, i got it now. Also now that i got that down, i set the jump to 50 to make my guy jump faster, but he jumps way to high and dont dissapers out of the scene, how could i make a roof to stop him from jumping out of the scene?

Response to Actionscript codes here! 2003-06-19 14:45:12


At 6/19/03 02:17 PM, Sub7Ecstacy wrote: thanx, i got it now. Also now that i got that down, i set the jump to 50 to make my guy jump faster, but he jumps way to high and dont dissapers out of the scene, how could i make a roof to stop him from jumping out of the scene?

How high he jumps is part of the variable you set to 50, so the lower that is, the lower the charater jumps. I do have a roof script for you.

1. Draw the roof and convert it to a movieclip
2. LABEL that movieclip "roof"
3. Add this code to the bottem of the script in your character, whre the rest of the jumping script also is:


onClipEvent (enterFrame) {
if (_root.roof.hitTest(this._x, this._y-50, true)) {
grav_y = -20;
}
}

Happy now?


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-19 15:46:10


The AI I want is that it follows the character intill a certian point and then shoots. Thats basically it thanks ahead of time.

Response to Actionscript codes here! 2003-06-19 17:59:31


can someone tell me the code that plays a frame when all the enemies are shot?

for example look at this
Example of a Shooter

Can u tell me the code that enables the GriffinRUN to pop up after like 3 enemies were shot?

Response to Actionscript codes here! 2003-06-19 18:57:13


I have a sequence of frames in a MC of my character walking. The onlytime i want the MC of him walking to play is when someone controls him with the left or right keys. Can anyone help me?

Response to Actionscript codes here! 2003-06-19 20:34:57


At 6/19/03 05:59 PM, FenixFlashFilms wrote: can someone tell me the code that plays a frame when all the enemies are shot?

for example look at this
Example of a Shooter

Can u tell me the code that enables the GriffinRUN to pop up after like 3 enemies were shot?

basically whenever a character dies killcount increases by 1 and if killcount reaches, in this case, 3 it goes and plays. It's all very simple. This is my shooter (I didn't add in enemies) :

http://www.thegeekhost.com/asclepeos/cam.swf

Response to Actionscript codes here! 2003-06-19 20:38:29


can u tell me the codes then.. like the code i would put onto the movie clip of every enemy and the last code to go to a certain frame??

Response to Actionscript codes here! 2003-06-19 21:51:44


I'm reluctant to just give out scripts. I deprive people of the learning experience. It's relatively simple. I'm sure you can figure it out if you just try and read some tutorials on basics of variables. If you still do'nt know then I'll post the code.

Response to Actionscript codes here! 2003-06-20 00:16:26


At 6/19/03 06:57 PM, Sub7Ecstacy wrote: I have a sequence of frames in a MC of my character walking. The onlytime i want the MC of him walking to play is when someone controls him with the left or right keys. Can anyone help me?

thats wat i was wanting to do b4. heres the code i used.

first inside the MC of your person make an MC or the person walking left in frame 2, an MC of the person walking right in frame 3 and a person standing still in frame 1. then add this code to the MC.

onClipEvnet(enterFrame){
//Move Left
if(Key.isDown(Key.LEFT)){
gotoAndStop(2);
//Move Right
}else if(Key.isDown(Key.RIGHT)){
gotoAndStop(3);
//Standing Still
}else if(!Key.isDown(Key.LEFT)){
gotoAndStop(1);
}else if(!Key.isDown(Key.RIGHT)){
gotoAndStop(1);
}
}

that should do the trick. it worked for me.

Now i need some help (sorry if this is getting annoying but im learning heaps).

ive got my guy to teleport to the oposite side of the screen wen he reaches the edge, now all i need is for the Background MC to go to the next frame wen he reaches an edge, can anyonw be of any help on this problem?


BBS Signature

Response to Actionscript codes here! 2003-06-20 01:06:19


At 6/20/03 12:16 AM, y3llow wrote:

Basically, just use the same script you have for when he teleports, but have a gotoAndPlay/gotoAndStop/nextFrame script.

if(this._x >= #){
_root.instanceName.nextFrame();
}

Response to Actionscript codes here! 2003-06-20 01:16:26


At 6/20/03 01:06 AM, PikaExploder wrote:
At 6/20/03 12:16 AM, y3llow wrote:
Basically, just use the same script you have for when he teleports, but have a gotoAndPlay/gotoAndStop/nextFrame script.

if(this._x >= #){
_root.instanceName.nextFrame();
}

thx man, ive been triing to do it that way for a while but i couldnt get the coding right.

that should do the trick.


BBS Signature

Response to Actionscript codes here! 2003-06-20 05:40:15


At 6/19/03 05:59 PM, FenixFlashFilms wrote: can someone tell me the code that plays a frame when all the enemies are shot?

for example look at this
Example of a Shooter

Can u tell me the code that enables the GriffinRUN to pop up after like 3 enemies were shot?

I think the terrorists are a movieclip, right? now, in the dying animation, you put a script, this one:

_root.kills += 1

(put that script in all dying-animations)
And that put this script in your mousepointer (the gun aimer wich is a movieclip too I guess)

onClipEvent (enterFrame) {
if (_root.kills > 2) {
getURL("http://www.griffinrun.com");
_root.kills=0;
}
}

And at last, but this script in the first frame of the movie:

kills=0

-Hope that helped!


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 05:59:50


At 6/20/03 12:16 AM, y3llow wrote:
At 6/19/03 06:57 PM, Sub7Ecstacy wrote: I have a sequence of frames in a MC of my character walking. The onlytime i want the MC of him walking to play is when someone controls him with the left or right keys. Can anyone help me?
thats wat i was wanting to do b4. heres the code i used.

first inside the MC of your person make an MC or the person walking left in frame 2, an MC of the person walking right in frame 3 and a person standing still in frame 1. then add this code to the MC.

onClipEvnet(enterFrame){
//Move Left
if(Key.isDown(Key.LEFT)){
gotoAndStop(2);
//Move Right
}else if(Key.isDown(Key.RIGHT)){
gotoAndStop(3);
//Standing Still
}else if(!Key.isDown(Key.LEFT)){
gotoAndStop(1);
}else if(!Key.isDown(Key.RIGHT)){
gotoAndStop(1);
}
}

that should do the trick. it worked for me.

Now i need some help (sorry if this is getting annoying but im learning heaps).

ive got my guy to teleport to the oposite side of the screen wen he reaches the edge, now all i need is for the Background MC to go to the next frame wen he reaches an edge, can anyonw be of any help on this problem?

Well, if you want him to telaport, you use this code:
onClipEvent (enterFrame) {
if (this._x > 550.0) {
this._x = 0;
}
if (this._x < 0) {
this._x = 550.0;
}
if (this._y > 400) {
this._y = 0;
}
if (this._y < 0) {
this._y = 400;
}
}
NOTE: HE WILL TELEPORT AT EVERY EDGE OF THE SCREEN!

To make the background diffrent (next frame) you first must label the background "background" and change the code I just told you into this:
onClipEvent (enterFrame) {
if (this._x > 550.0) {
this._x = 0;
tellTarget ("_root.background") {
nextFrame();
}
}
if (this._x < 0) {
this._x = 550.0;
tellTarget ("_root.background") {
nextFrame();
}
}
if (this._y > 400) {
this._y = 0;
tellTarget ("_root.background") {
nextFrame();
}
}
if (this._y < 0) {
this._y = 400;
tellTarget ("_root.background") {
nextFrame();
}
}
}

Or if you already have an teleport system, add this to your code:
tellTarget ("_root.background") {
nextFrame();
}

Hope that helped


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 06:30:01


At 6/20/03 05:59 AM, eviLudy wrote:

yea thats the exact same teleport code i used i think.

and that tellTarget command was the exact one i was looking for, i was sure u could do it but wasnt sure of the code.

Anyways im gonna experiment but what does everyone think:

Should i make the game so when u reach the edge of the screen the next background comes up?

Or should i just make it a continously moving background where it moven when the person moves?

P.S. The game is viewed from above so your looking down on everything.


BBS Signature

Response to Actionscript codes here! 2003-06-20 06:57:34


I think a diffrent background is the best


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 07:38:18


At 6/20/03 06:57 AM, eviLudy wrote: I think a diffrent background is the best

ill make both and put them on the net for everyone to check out and post on


BBS Signature

Response to Actionscript codes here! 2003-06-20 11:13:22


At 5/2/03 03:02 AM, eviLudy wrote: I just got myself a book Flash MX actionscript ans i've learned a lot already. So i'll post some codes. You should post too!

half those are samples. which is what i did to learn too so what can i say

Response to Actionscript codes here! 2003-06-20 11:26:23


At 5/10/03 01:36 AM, DeimosSaturn wrote: I'm simple. =3
What do you do to make a replay button at the very end of a movie and make it so the movie ends there instead of going back to the beggining?

in the frame where you want it to stop klick right>actions and if you have mx you go to actions> movie control and you double click the commando stop(in normal mode or just type in expert mode

stop();
------------------------------------------------------
to make a replay button

draw your button and convert it into a symbol with the instance of a button then right click on the button>actions and if you have flash mx go to actions>movie control>play and type in the scene number and frame number(this is normal mode) or type in expert mode

on (release) {
gotoAndPlay("type here scene number", type here frame number);

example to go to scene 1 frame 1:

on (release) {
gotoAndPlay("Scene 1", 1);

Response to Actionscript codes here! 2003-06-20 12:46:49


can someone plz tell me the instructions and the as code to make a percentage bar preloader

Response to Actionscript codes here! 2003-06-20 12:49:11


At 6/20/03 06:30 AM, y3llow wrote: and that tellTarget command was the exact one i was looking for, i was sure u could do it but wasnt sure of the code.

Don't get too attached to the tellTarget command. It's uses are limited, and it is deprecated. I don't know why eviLudy is using a tellTarget with a _root command. Use _root commands and dot syntax next time.

_root.background.nextFrame()

Response to Actionscript codes here! 2003-06-20 13:21:05


At 6/20/03 12:46 PM, Russian_Mobster wrote: can someone plz tell me the instructions and the as code to make a percentage bar preloader

-You can always take the bar from the NG preloader And here's a tutorial for a percentage:

1) Make a dynamic text box (no text in it) and give it the variable: _root.percent
2) Make a movieclip of that textbox
3) Add this script to your movieclip:

onClipEvent (enterFrame) {
b_loaded = _root.getBytesLoaded();
b_total = _root.getBytesTotal();
percent = Math.round((b_loaded/b_total)*100);
}

This will work if you have used the NG loader also, if you dont use the NG loader, then you also have to do this:
4) Draw a play button
5) Label it: "play"
6) Also add this script to the movieclip that contains your dynamic text box:
onClipEvent (load) {
tellTarget ("_root.play") {
_visible = false;
}
}
onClipEvent (enterFrame) {
if (_root.percent>=100) {
tellTarget ("_root.play") {
_visible = true;
}
}
}

That should do the trick


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 13:44:23


At 6/20/03 01:21 PM, eviLudy wrote: tellTarget ("_root.play") {
_visible = true;
}

Bah, I still don't get you eviLudy. Great actionscripter, but you should probably drop the tellTarget. You're getting commands all jumbled up. Try making one line of code instead of complicating it and using a tellTarget.

tellTarget ("_root.play") {
_visible = true;
}

Could be changed to:

_root.play._visible = true ;

One line. How hard is that?

Response to Actionscript codes here! 2003-06-20 14:01:07


while flash 4 syntax is deprecated they both work relatively the same. It's only when the processes reach over 6000+ per second that's when things get quirky. the deprecated flash 4 syntax tell target actually works faster than dot notation. let's say for example, dot notation:

1. go to the store, buy eggs
2. go to the store, buy meat
3. go to the store, buy salad

while tell target

1 go to the store, stay in store.
2. buy eggs
3. buy meat
4. buy salad.

for a computer and humans in general such subtle differences do not really matter. But when it goes on an on for thousands of more processes and loops it's 'comforting' for the flash player to know that it's still in the store. instead of getting annoyed by redundant information.

Response to Actionscript codes here! 2003-06-20 14:16:11


At 5/4/03 05:01 AM, eviLudy wrote: Gun Tutorial
________________________________
Then you make an laser dot, wich is the dot the gun aims to automaticly, and also make it a movieclip. Then put this code into the laserdot movieclip:

onClipEvent (enterFrame) {
this._x = _root._xmouse;
this._y = _root._ymouse;
}
onClipEvent (load) {
Mouse.hide();
}

how do make that when i klick with the laserdot i here a gunshot... i already have the gunshot sound in my library