Forum Topic: Actionscript codes here!

(210,167 views • 8,558 replies)

This topic is 286 pages long. [ 172144 | 145 | 146 | 147 | 148217286 ]

<< < > >>
Happy

PunkerFish

Reply To Post Reply & Quote

Posted at: 7/31/04 07:06 PM

PunkerFish EVIL LEVEL 08

Sign-Up: 03/21/04

Posts: 70

At 7/31/04 02:26 PM, _otacon_ wrote:
At 7/31/04 05:37 AM, PunkerFish wrote:
At 7/31/04 05:07 AM, _otacon_ wrote:
Umm....thats not what i meant and i needed the exact opposit of the problem on p145.

However, thanks dude. You just told me why my code didn't work.

Hehe...yeah. Glad I could help in some way.


Thinking

PunkerFish

Reply To Post Reply & Quote

Posted at: 8/1/04 02:04 AM

PunkerFish EVIL LEVEL 08

Sign-Up: 03/21/04

Posts: 70

Ok after trying desperately to fix EviLudy's jumping script to work productively I've come to one conclusion: It sucks.
I'm sure that with as brilliant as the people posting here are, we can make a good jumping script.
Though I can't be much of a help, I have made a simple falling script that may help others.

var direction:String;
function falling(){
if (player._y < 450) {
direction = "down";
}
if (direction == "down") {
player._y = player._y + 16;
}
}
_root.onEnterFrame = falling;

All you need to do is have a MC instance named 'player' and put that script in it's keyframe and it should work. All it does is make him fall though. So I think others should add to this and help make a working jump script for everybody who visits this page.


Happy

kusosuke

Reply To Post Reply & Quote

Posted at: 8/3/04 02:17 PM

kusosuke LIGHT LEVEL 12

Sign-Up: 12/15/03

Posts: 965

wow, i suck at AS, but thanks to this thread im getting better! thanks to everyone who posted AS codes of any kind on here!!


None

kusosuke

Reply To Post Reply & Quote

Posted at: 8/3/04 02:36 PM

kusosuke LIGHT LEVEL 12

Sign-Up: 12/15/03

Posts: 965

can anyone tell me the code to switch between the character walking movie clip and the caharacter standing still movie clip when you pres one of the arrow keys/let go of one of the arrow keys?
o and btw this thread really helps.


None

kusosuke

Reply To Post Reply & Quote

Posted at: 8/3/04 03:59 PM

kusosuke LIGHT LEVEL 12

Sign-Up: 12/15/03

Posts: 965

umm, this is gonna make me sound like im a retard or somthing, but how do you make walls?


None

FFKing

Reply To Post Reply & Quote

Posted at: 8/4/04 06:20 AM

FFKing EVIL LEVEL 06

Sign-Up: 12/13/03

Posts: 358

You draw them! XD
If u mean they cant go thru them, just to this:
find out the ._x positions of the walls u built.
(and assuming the walls are 10 and 500, do this:
onClipEvent(enterframe){
if(this._x <10.0){
this._x = 11.0;
}
if(this._x > 500.0){
this._x =499.0;
}
}
what that is saying is that if ur character reaches a certain point it will move it one pixel back, and vice versa for the other side. You may need to fiddle around with this etc.
Hope it helps.


Questioning

kusosuke

Reply To Post Reply & Quote

Posted at: 8/4/04 03:05 PM

kusosuke LIGHT LEVEL 12

Sign-Up: 12/15/03

Posts: 965

the walls dont work for me, but i have another question:
how do you make somthing snap in place, like in a jigsaw puzzle game?


None

GrandAdmiralThrawn

Reply To Post Reply & Quote

Posted at: 8/4/04 05:49 PM

GrandAdmiralThrawn EVIL LEVEL 11

Sign-Up: 08/14/03

Posts: 57

What's the code so that when your score equals a certain number you go to a certain frame . I've tried so many different scripts but none of them work. Anybody know the right script?


Thinking

PunkerFish

Reply To Post Reply & Quote

Posted at: 8/4/04 06:28 PM

PunkerFish EVIL LEVEL 08

Sign-Up: 03/21/04

Posts: 70

At 8/4/04 05:49 PM, GrandAdmiralThrawn wrote: What's the code so that when your score equals a certain number you go to a certain frame . I've tried so many different scripts but none of them work. Anybody know the right script?

onEnterFrame=function(){
if(score = number){
gotoAndPlay(frame);
}
}

Just replace 'number' with the number of the score you need to advance and 'frame' with the frame you go to.


None

GrandAdmiralThrawn

Reply To Post Reply & Quote

Posted at: 8/4/04 06:35 PM

GrandAdmiralThrawn EVIL LEVEL 11

Sign-Up: 08/14/03

Posts: 57

Thanks. What I had before was close along those lines.


None

kusosuke

Reply To Post Reply & Quote

Posted at: 8/4/04 07:45 PM

kusosuke LIGHT LEVEL 12

Sign-Up: 12/15/03

Posts: 965

lol i am asking alot of questions lately.....
what is the code to make a timer that tells you how much time youve spent on somthing? (NOT one that counts down)
also, i really need an answer to my puzzle question.


None

schorhr

Reply To Post Reply & Quote

Posted at: 8/4/04 07:48 PM

schorhr NEUTRAL LEVEL 11

Sign-Up: 05/28/02

Posts: 9,029

Well you just use

secondsSinceFlashStarted=getTimer()/1000;

and subtract a variable StartTiming, which also gets the time in a keyframe maybee.

getTimer()/1000 will be x.x seconds.


None

x-icicle-x

Reply To Post Reply & Quote

Posted at: 8/4/04 09:58 PM

x-icicle-x NEUTRAL LEVEL 11

Sign-Up: 03/13/04

Posts: 74

Do you guys know if theres a tutorial anywhere for a strategy game? Like slacker... I already know how to do it, I'm just wondering if theres a simpler way.


None

Newrad

Reply To Post Reply & Quote

Posted at: 8/4/04 10:03 PM

Newrad LIGHT LEVEL 07

Sign-Up: 05/26/04

Posts: 48

um i really need help... i am working on a game and i was wondering what code to use to make the A or D button do a sertant thing like if(Key.isDown(Key._____)) for the A and D key also for the rightclick button. um if i dont explain it good enough talk to me on aim please!


None

KirbyMeister

Reply To Post Reply & Quote

Posted at: 8/4/04 10:09 PM

KirbyMeister LIGHT LEVEL 06

Sign-Up: 01/01/04

Posts: 43

At 8/4/04 09:58 PM, x_icicle_x wrote: Do you guys know if theres a tutorial anywhere for a strategy game? Like slacker... I already know how to do it, I'm just wondering if theres a simpler way.

What, write an entire strategy game? Hrm... that would require a lot of action script...


Thinking

PunkerFish

Reply To Post Reply & Quote

Posted at: 8/4/04 11:37 PM

PunkerFish EVIL LEVEL 08

Sign-Up: 03/21/04

Posts: 70

At 8/4/04 10:03 PM, Newrad wrote: um i really need help... i am working on a game and i was wondering what code to use to make the A or D button do a sertant thing like if(Key.isDown(Key._____)) for the A and D key also for the rightclick button. um if i dont explain it good enough talk to me on aim please!

You can try this:

on (keyPress "a") {
_root.movieClip.play();
}

My AIM is NG PunkerFish if you need more help.


None

Skribble-Style

Reply To Post Reply & Quote

Posted at: 8/5/04 01:11 AM

Skribble-Style EVIL LEVEL 07

Sign-Up: 05/18/03

Posts: 65

At 8/4/04 10:03 PM, Newrad wrote: um i really need help... i am working on a game and i was wondering what code to use to make the A or D button do a sertant thing like if(Key.isDown(Key._____)) for the A and D key also for the rightclick button. um if i dont explain it good enough talk to me on aim please!

no problem u have to use the corresponding ASCII code for the key. A=65 and D=68, so u would just add this to ur MC

onClipEvent (enterFrame) {
if (Key.isDown(68)) {
this._x += 10;
} else if (Key.isDown(65)) {
this._x -= 10;
}
}

hope that helped


None

Skribble-Style

Reply To Post Reply & Quote

Posted at: 8/5/04 01:14 AM

Skribble-Style EVIL LEVEL 07

Sign-Up: 05/18/03

Posts: 65

i just assumed u wanted to move a character with it, but if u want it to do sumthing else just replace the " this._x" with woteva u want it to do.


Questioning

PunkerFish

Reply To Post Reply & Quote

Posted at: 8/5/04 04:16 AM

PunkerFish EVIL LEVEL 08

Sign-Up: 03/21/04

Posts: 70

At 8/5/04 01:11 AM, Skribble_Style wrote: no problem u have to use the corresponding ASCII code for the key.

Or you could do that...hehe.

I have a dynamic text box for my character's life (starting at 100) and certain enemies to damage in decimals (i.e. 2.2 damage) I was wondering if there is a way to have the 'life' text round to the nearest tenth.


Questioning

My-own-madness

Reply To Post Reply & Quote

Posted at: 8/5/04 07:49 AM

My-own-madness EVIL LEVEL 07

Sign-Up: 06/09/04

Posts: 47

I need help. How do I make a code to save if some variables are true or false in another person´s computer?


None

ouiskipoiski

Reply To Post Reply & Quote

Posted at: 8/5/04 08:00 AM

ouiskipoiski NEUTRAL LEVEL 06

Sign-Up: 05/29/04

Posts: 90

would anybody here be able to teach some basic action script?


Questioning

THE-KRAZYMAN

Reply To Post Reply & Quote

Posted at: 8/5/04 09:43 AM

THE-KRAZYMAN LIGHT LEVEL 09

Sign-Up: 07/03/04

Posts: 1,067

does any one no how to make an enemy move randomly across the screen.


None

Newrad

Reply To Post Reply & Quote

Posted at: 8/5/04 11:52 AM

Newrad LIGHT LEVEL 07

Sign-Up: 05/26/04

Posts: 48

no problem u have to use the corresponding ASCII code for the key. A=65 and D=68, so u would just add this to ur MC

onClipEvent (enterFrame) {
if (Key.isDown(68)) {
this._x += 10;
} else if (Key.isDown(65)) {
this._x -= 10;
}
}

hope that helped

thanks very very much but how would i make a righ clickfunction?


None

schorhr

Reply To Post Reply & Quote

Posted at: 8/5/04 12:02 PM

schorhr NEUTRAL LEVEL 11

Sign-Up: 05/28/02

Posts: 9,029

Correct me if I am wrong, but you cant (flash player uses the right click for internal menu).

You could use something like SHIFT+Left click
for example. OR CONTROL...


Questioning

adzki-y2k4

Reply To Post Reply & Quote

Posted at: 8/5/04 12:25 PM

adzki-y2k4 NEUTRAL LEVEL 04

Sign-Up: 04/17/04

Posts: 5

Right i'm ueslessly confused here >:(
I want to make it so my car drives like a real car, i mean like turns by rotation etc etc, I want to make it so it stops if it hits another car, and i want to make a square which when the car stops in it takes you to another frame?
I wouldn't mind if you would help me with either of these. Thanks a lot.


None

Newrad

Reply To Post Reply & Quote

Posted at: 8/5/04 12:33 PM

Newrad LIGHT LEVEL 07

Sign-Up: 05/26/04

Posts: 48

At 8/5/04 12:02 PM, schorhr wrote: Correct me if I am wrong, but you cant (flash player uses the right click for internal menu).

You could use something like SHIFT+Left click
for example. OR CONTROL...

yeah i think you are right cuz i tryed everything and so i think im just going to use like the w key but ok thanks


None

flashtoflash55

Reply To Post Reply & Quote

Posted at: 8/5/04 12:36 PM

flashtoflash55 LIGHT LEVEL 06

Sign-Up: 06/20/04

Posts: 92

At 8/5/04 12:25 PM, adzki_y2k4 wrote: Right i'm ueslessly confused here >:(
I want to make it so my car drives like a real car, i mean like turns by rotation etc etc, I want to make it so it stops if it hits another car, and i want to make a square which when the car stops in it takes you to another frame?
I wouldn't mind if you would help me with either of these. Thanks a lot.

Well, If you want a realistic car then put this script in your car!!

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed += .6;
//acceleration;
}
if (Key.isDown(Key.DOWN)) {
if (speed > 0) {
speed -= 1;
//brakes;
}
}
if (Math.abs(speed)>25) {
//max speed;
speed *= .7;
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.4;
//recovery after hitting a wall;
}
if (speed <> 0) {
if (Key.isDown(Key.RIGHT)) {
_rotation += (speed + 2)/4;
//now turning is a function of the speed: the faster you're going, the more you can turn;
//this gives the illusion of realism. between this and acc, it seems like a real car!;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= (speed + 2)/4;
}
}
}

Someone posted it a long time ago!!and if you want it to go to another scene when it hits the square, it ill sort of take a while to explain, so go to This Sight sign up and go to the flash forum!! I'll explain every thing there!!


None

Newrad

Reply To Post Reply & Quote

Posted at: 8/5/04 12:44 PM

Newrad LIGHT LEVEL 07

Sign-Up: 05/26/04

Posts: 48

i have one more question how would i have like a function like s+click?


None

Skribble-Style

Reply To Post Reply & Quote

Posted at: 8/5/04 01:24 PM

Skribble-Style EVIL LEVEL 07

Sign-Up: 05/18/03

Posts: 65

PunkerFish - u need to use Math.floor, Math.floor returns the floor of the number or expression specified in the parameter x. The floor is the closest integer that is less than or equal to the specified number or expression.

Example:
The following code returns a value of 12:

Math.floor(12.5);

My_own_madness - Look into the "sharedObject" feature.

ouiskipoiski - LoL man just look through the 140+ pages here and u will learn tons.

THE-KRAZYMAN - can u elaborate a little? wot do u mean randomly across the screen?

Newrad - u can have a custom rightclick menu but only in .exe flash movies.

as for the s+click code it would be sumthing like....

onClipEvent(mouseDown){
if(Key.isDown(83)){
//menu code
}
}


None

Newrad

Reply To Post Reply & Quote

Posted at: 8/5/04 02:30 PM

Newrad LIGHT LEVEL 07

Sign-Up: 05/26/04

Posts: 48

Newrad - u can have a custom rightclick menu but only in .exe flash movies.

as for the s+click code it would be sumthing like....

onClipEvent(mouseDown){
if(Key.isDown(83)){
//menu code
}
}

k thanks alot^_^


All times are Eastern Standard Time (GMT -5) | Current Time: 03:30 AM

<< Back

This topic is 286 pages long. [ 172144 | 145 | 146 | 147 | 148217286 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!