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

Response to Actionscript codes here! 2004-10-15 05:52:33


C'mon people!

Does nobody know how to do this?

Retrieve a variables value through a value that is made up of strings.

eg.
//fixed variables: americaDmg = 10; gunDmg = 10;
dmgAmt = array[iX] + "Dmg" (if iX = 1 & 1 = "gun".. then array[iX] + "Dmg" = gunDmg...

I'm looking to remove gunDmg from hitPoints, but "gunDmg" is seen as a string and not a variable.

Please help... this has put my project on hold and the sooner I can move on, the sooner NG gets to taste it's flavour.

Response to Actionscript codes here! 2004-10-15 06:46:18


technically i don't see the problam with doing it,
try this
chararr="_alpha";
trace(_root[chararr]);
try this
p.s. the [] aren't array [] they are value [],

Response to Actionscript codes here! 2004-10-15 07:38:22


At 10/15/04 01:58 AM, Joshman_123 wrote: You are an idiot Frenchi.

Ouch, my poor ego. I might just go cry, you know how upset I get when anonymous strangers think they can secure their own masculinity by insulting my person.

Good day to you sir.

-Frenchi

Response to Actionscript codes here! 2004-10-15 08:34:41


nice work here guy

Response to Actionscript codes here! 2004-10-15 09:24:52


ummmm..........WTF! i do the GTA style movement and stuff tutorial featured on the website
http://flashregs.x3fusion.com/tutview.php?t=236

this is the tutorial......
Step 2
Draw your character
-Should be a circle. Top viewed. You should be able to see what the characters front side is too. Character should basicly be facing the UP direction. Convert it to a movieclip (F8) and give it the instance name 'Character'

Step 3
Draw your Car
-Should basicly be a block. Convert it to movieclip. (F8) give it the instance name 'car'

Step 4
Apply the following actions
-Apply these actions to your character movieclip. lines that start with // are comments. They explain the code.

Response to Actionscript codes here! 2004-10-15 09:28:00


ummmm..........WTF! i do the GTA style movement and stuff tutorial featured on the website
http://flashregs.x3fusion.com/tutview.php?t=236

this is the tutorial......
Step 2
Draw your character
-Should be a circle. Top viewed. You should be able to see what the characters front side is too. Character should basicly be facing the UP direction. Convert it to a movieclip (F8) and give it the instance name 'Character'

Step 3
Draw your Car
-Should basicly be a block. Convert it to movieclip. (F8) give it the instance name 'car'

Step 4
Apply the following actions
-Apply these actions to your character movieclip. lines that start with // are comments. They explain the code.

onClipEvent (enterFrame) {
// Applies this action in the time if every frame. If your framerate is 12, 12 times a second
if (Key.isDown(Key.RIGHT)) {
// Action is only played when RIGHT key is pressed.
_rotation = _rotation+move;
// Adds the value that 'move' has to the rotation degrees of the movieclip.
}
if (Key.isDown(Key.LEFT)) {
// Action is only played when LEFT key is pressed.
_rotation = _rotation-move;
// Subtracts the value that 'move' has from the rotation degrees of the movieclip.
}
if (Key.isDown(Key.UP) && !this.hitTest(_root.car)) {
// Action is only played when UP key is pressed. AND when character does not collide with car
if (move<8) {
// Action is only played when the variable 'move' is smaller than 8
move++;
// Adds 1 to the variable 'move'
move++;
// Adds 1 to the variable 'move'
}
} else if (move>0) {
// Action is only played when the variable 'move' is bigger than 0
move--;
// Subtracts 1 from the variable 'move'
move--;
// Subtracts 1 from the variable 'move'
}
if (Key.isDown(Key.DOWN)) {
// Action is only played when DOWN key is pressed.
if (move>-10) {
// Action is only played when the variable 'move' is bigger than -10
move--;
// Subtracts 1 from the variable 'move'
move--;
// Subtracts 1 from the variable 'move'
}
} else if (move<0) {
// Action is only played when the variable 'move' is smaller than 0
move++;
// Adds 1 to the variable 'move'
move++;
// Adds 1 to the variable 'move'
}
if (_rotation>180) {
// Applies the action only when the rotation of the movieclip is bigger than 180
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
// Applies the action only when the rotation of the movieclip is smaller than 180
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}

Step 5
Apply the following actions
-Apply these actions to your car movieclip. lines that start with // are comments. They explain the code.

onClipEvent (enterFrame) {
// Applies this action in the time if every frame. If your framerate is 12, 12 times a second
if (_root.ride == 1) {
// Applies this action only if the variable 'Ride' is 1
if (Key.isDown(Key.ENTER)) {
_root.character._visible = true;
_root.character._x+=15;
_root.ride = 0;
}
_root.character._x = _x;
_root.character._y = _y;
// Makes the character have the same coordinates as the Car
if (Key.isDown(Key.RIGHT)) {
// Action is only played when RIGHT key is pressed.
_rotation = _rotation+move;
// Adds the value that 'move' has to the rotation degrees of the movieclip.
}
if (Key.isDown(Key.LEFT)) {
// Action is only played when LEFT key is pressed.
_rotation = _rotation-move;
// Subtracts the value that 'move' has from the rotation degrees of the movieclip.
}
if (Key.isDown(Key.UP)) {
// Action is only played when UP key is pressed. AND when character does not collide with car
if (move<8) {
// Action is only played when the variable 'move' is smaller than 8
move++;
// Adds 1 to the variable 'move'
move++;
// Adds 1 to the variable 'move'
}
} else if (move>0) {
// Action is only played when the variable 'move' is bigger than 0
move--;
// Subtracts 1 from the variable 'move'
move--;
// Subtracts 1 from the variable 'move'
}
if (Key.isDown(Key.DOWN)) {
// Action is only played when DOWN key is pressed.
if (move>-10) {
// Action is only played when the variable 'move' is bigger than -10
move--;
// Subtracts 1 from the variable 'move'
move--;
// Subtracts 1 from the variable 'move'
}
} else if (move<0) {
// Action is only played when the variable 'move' is smaller than 0
move++;
// Adds 1 to the variable 'move'
move++;
// Adds 1 to the variable 'move'
}
if (_rotation>180) {
// Applies the action only when the rotation of the movieclip is bigger than 180
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
// Applies the action only when the rotation of the movieclip is smaller than 180
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}
}
onClipEvent (enterFrame) {
if (_root.ride == 0 && this.hitTest(_root.character) && Key.isDown(Key.ENTER)) {
_root.character._visible = false;
_root.ride = 1;
}
}
onClipEvent (load) {
_root.ride = 0;
}

Step 6
You're done
-There is no step 6. This tutorial is over.

every bit of the actionscripting part is correct, but when i try it out......the character moves and stuff but when i try and enter the car and drive away, thats where it goes wrong............like first of all the character colides with the car and second of all when i try and enter the car it won't let me.....

can someone please help me out, please!!!!!!!!!!!!!

Response to Actionscript codes here! 2004-10-15 10:22:15


onClipEvent (enterFrame) {
if (_root.ride == 0 && this.hitTest(_root.character) && Key.isDown(Key.ENTER)) {
_root.character._visible = false;
_root.ride = 1;
}
}

In the above code, just remove the line that says "onClipEvent (enterFrame) {" and also the bracket right there under "_root.ride = 1;"

Response to Actionscript codes here! 2004-10-15 10:42:31


on(release){
_root._quality="LOW"
}

You could also use "MEDIUM" or "HIGH" rather then low. You could also make an if that detects the quality and changes it accordingly. Or you can take the easy way and use 3 buttons.

Response to Actionscript codes here! 2004-10-15 11:52:01


At 10/15/04 09:28 AM, captain_america1 wrote: stuff

your point is? alot of people programmed gta style movement...

Response to Actionscript codes here! 2004-10-15 15:04:26


wow.. who would've known a year and 8 months a go that this thread would have over 5000 posts, well done I guess Luders.

Response to Actionscript codes here! 2004-10-15 18:45:50


What does && mean is Actionscript?

Response to Actionscript codes here! 2004-10-15 19:18:03


&& is the logical "AND" operator. It connects two Boolean (true/false or 1/0) statements, and returns 1 (true) if boths are true, and 0 (false) in any other case.

Response to Actionscript codes here! 2004-10-16 07:51:31


aahhhhhh, i've given up on the GTA style movement tutorial......

more help needed,
i have created a pause, play and mute button for a flash movie that i am making.....
the mute button works, it stops all sounds but how can i get it to play all sounds again............
the pause and play button work with the normal stop () and play ()
actionscripting bit, but the music continues to play
and one more thing, how do i create a scroll bar, for example in Windows Media Player and WinAmp, you can drag the bar over and play a certain part of the song or movie..........another example of what i am after is in Final Fantasy A+

so can some one please tell me how to .....
A) get the music playing again after i have muted it
B) tell me how i can get the stop and play buttons to also stop the music and play the music again
and....
C) how to create a scroll bar to use for my movie

thanks i will appreciate the help...........

Response to Actionscript codes here! 2004-10-16 08:09:32


nice thanks


4 8 15 16 23 42

would you kindly?

|N|E|W|G|R|O|U|N|D|S| my antidrug

BBS Signature

Response to Actionscript codes here! 2004-10-16 09:21:15


At 10/16/04 08:09 AM, dabboy wrote: nice thanks

for what? you didn't ask anything...

Response to Actionscript codes here! 2004-10-16 09:22:17


At 10/16/04 08:09 AM, dabboy wrote: nice thanks

for what? you didn't ask anything...

Response to Actionscript codes here! 2004-10-16 11:25:56


Captain america
s.setVolume(100); this is volume control. for mute, just use this code and set it to 0, and set back to 100 when unmuted. you can do the same with stop and play.

Ive got a question, im making a rather long rpg and i need a save and load feature on it. if anyone could give me the code or a website with the code on it, that would be great. thanks.


BBS Signature

Response to Actionscript codes here! 2004-10-16 11:28:23


At 10/16/04 07:51 AM, captain_america1 wrote: A) get the music playing again after i have muted it

Sound Through ActionScript- Use this tutorial

B) tell me how i can get the stop and play buttons to also stop the music and play the music again

Use the above tutorial.

C) how to create a scroll bar to use for my movie

Movie Nav Bar- Look out for this tutorial. I've yet to finish it but I'll try to get it done today.

Response to Actionscript codes here! 2004-10-17 05:37:06


At 10/16/04 11:28 AM, Deathcon7 wrote:

stuff

Thankyou very much Deathcon7, it was very helpful, yay, IT NOW WORKS, thankyou

Response to Actionscript codes here! 2004-10-17 06:14:08


At 10/17/04 05:37 AM, captain_america1 wrote:
At 10/16/04 11:28 AM, Deathcon7 wrote:
stuff

Thankyou very much Deathcon7, it was very helpful, yay, IT NOW WORKS, thankyou

well i was lying b4, well i replied b4 i did the tutorial so yeah.......im so stupid.....

na anyway, i have done the linkage part and called it starwarsmaintheme...........but i am confused as to where the first code of......
mySound=new Sound();
mySound.attachSound(Identifier);
//to play a sound
mySound.start([offset, Num of Loops]);
//to stop a sound
mySound.stop([Identifier]);

what i understand from ur tutorial would be that you would change the name of mySound to starwarsmaintheme
and identifier as starwarsmaintheme......or am i getting it all wrong, please help me out again.......sorry for being a p#@ck..........

Response to Actionscript codes here! 2004-10-17 07:07:34


Juice Tin i may have the right tutorial for ya.........

go to this website listed below, it sounds like it would do the trick
http://www.flashkit.com/tutorials/Games/SaveLoa-fwe4life-1037/index.php

yeah it sounds exactly what u are after..........

now with ur help that u gave me saying s.setvolume(100) or what eva it was..............i am just curious as to what the s means?........the music that i wan't to stop and play etc....is called StarWarsMainTheme.mp3 so i am just curious as to exactly how ur s.setvolume thingo works...please respond

Response to Actionscript codes here! 2004-10-17 13:44:46


Hey
I need help
I wanna make a cool game its my dream I was looking through page 1 and 2 for the actionsript for AI but then I just posted

A.You see how do you make someone move like the main character movie when you press Left,Right,Up,Down

B.And If I make a fighting game and then how do you make the person attack then the enemy's Life Points go downn and then how do you make the enemy attack you and your life points go down?Oh and how do you make if the enemy's power reaches 0 you go to the next level or something and if the main person's power reaches 0 you go to the beggining

C.And how do you make an adventure game like Alien Homnid or Pico 2(Which everybody knows hows it gonna be)

D.and how do you like make if you go into a wall you stop

E.And how do you make if you go to a ledge and then Die?

Please tell Me(^_^)

Response to Actionscript codes here! 2004-10-18 01:51:52


KTH, just go to www.flashkit.com and search for what you are after, but for your search be specific............

but for ur first question this is the code you use to make ur character go left, right, up and down......
add this to your character after making he or she or it a movie clip....

onClipEvent (load) {
moveSpeed = 19;
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown (Key.UP)) {
this._y -= moveSpeed;
} else if (Key.isDown (Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown (Key.LEFT)) {
this._x -= moveSpeed;
}
}

if you want ur character to move faster or slower just increase the value of the movement speed....

but for your other questions basically search flashkit.com and hopefully u will get the answers u are looking for.......

Response to Actionscript codes here! 2004-10-18 05:36:17


hey im making a tactics game where you can walk with characters and trow things to eachother but i have a movieclip of a character and in that movieclip is the instance of the first frame 0moires, the second 30moires, the third 60moires till the twelfth frame is 330moires (moires is angle in degrees in greek) and in each frame you see the character from another position and now if you move with the mouse he turns to it and i want that if you click somewhere, the character moves to there and i already have an actionscript for it but it doesnt work, please look on it for if there are things that arent good and then tell the good script to me. moeko is the character and has 12 positions to look to.

_root.speed = 2;
// xmou and ymou are for that the character dont move imediatly to the mouse when the movie is loaded
xmou = _root.moeko._x;
ymou = _root.moeko._y;
// 2 arrays each with 8 values (degrees)
moires1 = [0, 22.6, 66.6, 111.6, 156.6, 202.6, 247.6, 294.6];
moires2 = [22.5, 66.5, 111.5, 156.5, 202.5, 247.5, 294.5, 340.5];
// a new array with the frame label names of the moeko movie
rotate = ["0moires", "30moires", "60moires", "90moires", "90moires", "120moires", "150moires", "180moires", "210moires", "240moires", "270moires", "300moires", "330moires"];
onEnterFrame = function () {
// the angle in radians between the clip and the mouse
radians = -Math.atan2(moeko._y-_root._ymouse, moeko._x-_root._xmouse);
// convert radians to degrees
degrees = radians*180/Math.PI+180;
// for i=0 and as long as i is not bigger than the array's length moires1 which is 8
for (i=0; i<=moires1.length; ++i) {
// if the value of the degrees variable is between moires1[i] and moires2[i]
// the caseTrue variable takes the value of the array rotate[i]
// ----------------
// for eg if degrees = 44 then 44 is between the value of the arrays
// moires1[2] and moires2[2] so caseTrue = rotate[2]
// rotate[2] = "45moires" that is why caseTrue is equal to "45moires"
// ----------------
// else if degrees is between 340.5 and 360 then caseTrue = "0moires"
if (degrees>=moires1[i] && degrees<=moires2[i]) {
caseTrue = rotate[i];
} else if (degrees>340.5 && degrees<=360) {
caseTrue = rotate[0];
}
}
// the following lines just tell the movie clip to move to, where the mouse was last clicked
while (j++, j<_root.speed) {
with (_root.moeko) {
_root.moeko._x += (xmou-_root.moeko._x)/18;
_root.moeko._y += (ymou-_root.moeko._y)/18;
}
}
j = 0;
};
onMouseDown = function () {
// xmou & ymou take the value of the x and y mouse position when you click it
xmou = _root._xmouse;
ymou = _root._ymouse;
// go to and stop in the frame with the same label name as the variable caseTrue
_root.moeko.gotoAndStop(caseTrue);
};

Actionscript codes here!

Response to Actionscript codes here! 2004-10-18 07:45:30


sorry, but i don't know actionscripting very well duckbaker....

what i need to know is, i have worked out how to turn the volume down via a volume control button with like dynamic texts and stuff............but what i want to know is when i click on the pause button, how to stop the music at that EXACT spot so when i click on play it will continue playing the music or sound etc...........

Response to Actionscript codes here! 2004-10-18 10:45:20


At 10/18/04 05:36 AM, duckbaker wrote:

:stuff

dude! you already did the harder part, now all you have to do left is duplicate a movie clip and paste it at the mouse's x and y on press, and set a var to true,

make the char move in that direction with a simple script
if( _x>_dot._x){
this._x-=speed;
}else{
this._x+=speed;
}
something like that, and when it hits the dot, make that var from before to false and remove the dot (removemovieclip(this));

Response to Actionscript codes here! 2004-10-18 10:46:37


At 10/18/04 05:36 AM, duckbaker wrote:

:stuff

At 10/18/04 05:36 AM, duckbaker wrote:

:stuff

dude! you already did the harder part, now all you have to do left is duplicate a movie clip and paste it at the mouse's x and y on press, and set a var to true,

make the char move in that direction with a simple script
if( _x>_dot._x){
this._x-=speed;
}else{
this._x+=speed;
}
something like that, and when it hits the dot, make that var from before to false and remove the dot (removemovieclip(this));

Response to Actionscript codes here! 2004-10-18 11:05:17


tank yuo

Response to Actionscript codes here! 2004-10-19 20:41:19


Hey..... I feel imbaressed asking this and I'm to lazy to look through 175 pages of posts.... Can somebody here tell me how to make an actionscripted particle effect? Please? I'm really looking for the flame effect more then anything else. ...


And as he lay dying he whispered,

"I wonder if they'll write a song about me."

Response to Actionscript codes here! 2004-10-20 06:07:04


Oh and thanks uhhm That guy that gave me the movement code
But I really need to start submitting flash to newgrounds I just need these codes I just need 2...I'll look for more on flashkit

How do you make a Fighting game?
And I mean a fighting game like Xmen:Next Dimension and DBZ Budokai 2 where you can hit guys through walls and you have finishers and not a Fighting game where you attack and the opponent dosent.......I NEED AI!!

And how do you make someone move around and then meet enemys and fight them while you like walking...And how do you make a person attack a certain person and then like a movie follows it?