00:00
00:00
Newgrounds Background Image Theme

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

426,538 Views | 7,948 Replies
New Topic

Response to Actionscript codes here! 2006-12-20 05:15:42


I'm sure somebody in here will be able to help me...

Im working on a simple interface that require the user to zoom in and drag a map to find certain objects in a game.

First of all, when the "zoom in" button is clicked, the movie clip simply increases in size (dont know of another way to do it), but always zooms in towards the center of the map. So, you always have to keep dragging around to get back to where you were looking. I dont want a feature that zooms wherever you click though. Simply, I need a way for the current position to be kept when zoom in/zoom out is clicked.

Next is about the dragging... If you drag the map far enough, everything looks rather blank and you might not even be able to drag it back and have to end up refreshing the page. I'm trying to make a feature that loops the map horizontally, so one could drag endlessly...but at the same time there must be a barrier vertically. The barrier needs to work in a way that it still allows zooming in, but remains at the top and bottom when you try to drag the map up/down.

For me, both of these ideas are difficult enough, but they also have to work in harmony with each other. I hope someone can understand how I've laid this out...

Any script ideas would be greatly appreciated. I'm using Flash 8.

Heres my zoom script:

zoomin.onRelease = function():Void{
with (world){
_xscale += 25;
_yscale += 25;
}
};

zoomout.onRelease = function():Void{
with (world){
_xscale -= 25;
_yscale -= 25;
}
};

And my dragging script (basic startdrag took away button functionality for some reason):

onClipEvent (load) {
dragging = false;
}

onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
dragging = true;

xOffset = this._x - _root._xmouse;
yOffset = this._y - _root._ymouse;
}
}

onClipEvent (enterFrame) {
if (dragging) {
this._x = _root._xmouse + xOffset;
this._y = _root._ymouse + yOffset;
}
}

onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
dragging = false;
}
}

Response to Actionscript codes here! 2006-12-20 07:31:18


i need help! i got a code like i press the shift key and i fire a bullet but i only make the bullet go right. I NEED HEEEELP!!

Response to Actionscript codes here! 2006-12-20 07:34:55


SavvaS, try this:

on(release){
_root.gotoAndPlay(*)
}

Where the star is, add the frame the help page is on.

I'm making a tute and add buttons in.

Response to Actionscript codes here! 2006-12-20 10:28:22


Woah thanks a ton for the camera follow script!

Response to Actionscript codes here! 2006-12-20 12:22:40


i call this script:
DRAG FOREVER

sample:
http://img143.imageshack.us/my.php?image=endl essdrag2vc6.swf

map.onPress = function(){
mapDrag=true;
x=_xmouse-map._x;
y=_ymouse-map._y;
}
map.onRelease = function(){ mapDrag=false; }

map2.onPress = function(){
mapDrag2=true;
x=_xmouse-map2._x;
y=_ymouse-map2._y;
}
map2.onRelease = function(){ mapDrag2=false; }

map3.onPress = function(){
mapDrag3=true;
x=_xmouse-map3._x;
y=_ymouse-map3._y;
}
map3.onRelease = function(){ mapDrag3=false; }

map4.onPress = function(){
mapDrag4=true;
x=_xmouse-map4._x;
y=_ymouse-map4._y;
}
map4.onRelease = function(){ mapDrag4=false; }

onMouseUp = function(){ mapDrag=false; mapDrag2=false; mapDrag3=false; mapDrag4=false;}

function doThis(){

if(mapDrag==true){

map._x = _xmouse-x;
map._y = _ymouse-y;

if(map._x>0){map2._x=map._x-map._width;}
else{ map2._x=map._x+map._width;}

if(map._y>0){map3._y=map._y-map._height;}
else{ map3._y=map._y+map._height;}

map2._y = map._y;
map3._x = map._x;
map4._x=map2._x;
map4._y=map3._y;

}

if(mapDrag2==true){

map2._x = _xmouse-x;
map2._y = _ymouse-y;

if(map2._x>0){map._x=map2._x-map._width;}
else{ map._x=map2._x+map._width;}

if(map2._y>0){map4._y=map2._y-map._height;}
else{ map4._y=map2._y+map._height;}

map._y=map2._y;
map4._x=map2._x;
map3._x=map._x;
map3._y=map4._y;

}

if(mapDrag3==true){

map3._x = _xmouse-x;
map3._y = _ymouse-y;

if(map3._x>0){map4._x=map3._x-map._width;}
else{ map4._x=map3._x+map._width;}

if(map3._y>0){map._y=map3._y-map._height;}
else{ map._y=map3._y+map._height;}

map._x=map3._x;
map4._y=map3._y;
map2._x=map4._x;
map2._y=map._y;

}

if(mapDrag4==true){

map4._x = _xmouse-x;
map4._y = _ymouse-y;

if(map4._x>0){map2._x=map4._x-map._width;}
else{ map2._x=map4._x+map._width;}

if(map4._y>0){map3._y=map4._y-map._height;}
else{ map3._y=map4._y+map._height;}

map2._y=map4._y;
map3._x=map4._x;
map._x=map2._x;
map._y=map3._y;

}

} setInterval(function(){ doThis(); },10);

Response to Actionscript codes here! 2006-12-20 12:56:12


Here's some HUGE moving script I just compiled.

onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x+=speed;
} else if (Key.isDown(Key.LEFT)) {
this._x-=speed;
}
}
onClipEvent (load) {
jumping = false;
jSpeed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) && !jumping) {
jumping = true;
jSpeed = 10;
}
if (jumping) {
this._y-=jSpeed;
jSpeed--;
if (this.hitTest(_root.ground)) {
jumping = false;
jSpeed = 0;
}
}
}

Make a movieclip and add this in. Then make another clip and in the instance name, add ground.

Response to Actionscript codes here! 2006-12-20 15:04:32


Basic movement script:
on (keyPress "<Right>") { // When we press the arrow keys...
this._x=this._x+6 // Coordinates z(deep),y(down-up)x(left-right) changes...
} // End of block
on (keyPress "<Down>") {
this._y=this._y+6
}
on (keyPress "<Left>") {
this._x=this._x-6
}
on (keyPress "<Up>") {
this._y=this._y-6
}

Response to Actionscript codes here! 2006-12-20 17:49:41


i need a code for a back button that brings you back to the menu. Note-there is music playing and i need a code that wont start the music agan.

Response to Actionscript codes here! 2006-12-21 04:21:53


well,it may add seconds to the time,but you need to keep it accurate.Here's some code.Hope it helps!

_root.onEnterFrame = function() {
var date:Date = new Date();
var Hours = date.getHours();
var Minutes = date.getMinutes();
if (Hours<10) {
Hours = "0"+Hours;
}
if (Hours == 0) {
Hours = 12;
}
if (Hours>12) {
Hours-12;
}
if (Minutes<10) {
Minutes = "0"+Minutes;
}
_root.hours = Hours;
_root.minutes = Minutes;
};

All you have to do now is create a dynamic text box that has the number 12 in it.Give it an instance name of hours.Now create another text box with two zeros in it.Give this one an instance name of minutes.Add the actionscript to the ONLY keyframe in the entire movie. There should only be ONE and it should be the first one.Have fun!Oh,yeah, If you want the file to go to a different page each time it strikes...12 for example.Add this code to the frame with the actionscript above:

stop();

now go to frame 2 and add a keyframe.Make some text that says "It's 12 O'clock!!!"
Now go back to frame one andf inside the onEnterFrame function put this in:

if (Hours == 12) {
_root.gotoAndStop(2);
}

Now the entire code for the first frame should look like this:

stop();
_root.onEnterFrame = function() {
var date:Date = new Date();
var Hours = date.getHours();
var Minutes = date.getMinutes();
if (Hours<10) {
Hours = "0"+Hours;
}
if (Hours == 0) {
Hours = 12;
}
if (Hours>12) {
Hours-12;
}
if (Minutes<10) {
Minutes = "0"+Minutes;
}
_root.hours = Hours;
_root.minutes = Minutes;
if (Hours == 12) {
_root.gotoAndStop(2);
}
};

And there should be a second keyframe that has this text on it(on the stage,not in actionscript!)

it's 12 O'clock!!!!!!!

And there,your done!

Hope this helped!!!


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to Actionscript codes here! 2006-12-21 04:28:12


At 2/6/05 11:03 PM, Cloudv909 wrote: your fps, lets say its 15. Put 15 frames. If 30 then put 30. (you know) put as much frames in as the fps. Then add one more frame. on this frame add this code:
_root.seconds = _root.seconds+1; ...
-SwordDeath

sry about my last post.I was replying to this guy ^
|


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to Actionscript codes here! 2006-12-21 10:41:32


Holy freaking crap that map dragging script is EXACTLY what i wanted. I LOVE YOU.

...but i still feel the need to see other people.

Response to Actionscript codes here! 2006-12-21 10:54:43


yeah, I can action script fire and explosions but i have no idea how to do games! Roght noe I have a simple point and click game, but when the crosshairs hover above an enemy and you clikc, how do I make it so the guy dies?

Response to Actionscript codes here! 2006-12-21 12:22:20


At 12/21/06 10:54 AM, ojmosher wrote: yeah, I can action script fire and explosions but i have no idea how to do games! Right now I have a simple point and click game, but when the crosshairs hover above an enemy and you click,noting happens! How do I make it so the guy dies?

Lol.Spelling and grammar errors fixed in that.Sorry,but it just bugs me.Anyway,convert the enemy to a movie clip by pressing F8,and name it enemy.Now click ok,and give it an instance name of enemy.Now go inside the mc and make an animation of the guy dying.Go to the first frame of that animation and press F9 to open up the actions pannel.Put this in the first and last frames of the mc(I suggest that you remove the enemy by pressing \the delete key on the frame with the stop action):

stop();

Now go into the _root timeline by clicking on the button that says Scene 1.Now put this in the frame where your mc is.The frame,not the mc itself!!!

stop();
_root.enemy.onPress = function() {
_root.enemy.gotoAndPlay(2);
};

and there you go!!!


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to Actionscript codes here! 2006-12-21 13:23:18


or you could put:

onClipEvent (mouseDown){
if(this.hitTest(_root._xmouse, _root._ymouse)){
_root.enemy.play();
}
}

put that in your enemy! :D

Response to Actionscript codes here! 2006-12-21 13:26:21


Cool, i've done it now thanks for your help and grammer corrections! XD

Response to Actionscript codes here! 2006-12-21 14:52:41


Hey can anyone help me with this as problem i want it so that when the bat hits the monster it kill him and plays the death animation
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.circle.bat)) {
monster.gotoAndPlay(death);
}
}

Response to Actionscript codes here! 2006-12-21 15:05:38


At 5/4/03 11:14 PM, Link7 wrote: How do i make a MUTE button?

lol @ only post in 3 years


BBS Signature

Response to Actionscript codes here! 2006-12-21 21:19:52


So can anyone help with my actionscript question..?

Response to Actionscript codes here! 2006-12-21 23:04:52


decent pong:

ball = function () {
this.convert = Math.PI/180;
this.convertb = 180/Math.PI;
this.xspd = 0;
this.yspd = 0;
this.rotation = 35;
this.angone = 0;
this.diff = 0;
this.pointa = 0;
this.pointb = 0;
this.i = 0;
this.l = 0;
this.spd = 1.5;
this.hit = false;
this.found = false;
this.xarr = new Array();
this.yarr = new Array();
for (this.i=0; this.i<(360); this.i += 10) {
this.xarr.push(3*Math.sin(this.i*(this.conver t)));
this.yarr.push(3*Math.cos(this.i*(this.conver t)));
}
};
ball.prototype = new MovieClip();
Object.registerClass("ball", ball);
ball.prototype.moving = function(dir) {
this.xspd = Math.sin(this.rotation*(this.convert));
this.yspd = Math.cos(this.rotation*(this.convert));
this._x += this.xspd*this.spd*dir;
this._y -= this.yspd*this.spd*dir;
};
ball.prototype.colission = function() {
this.hit = false;
delete (this.colissionarr);
this.colissionarr = new Array();
for (this.i=0; this.i<36; this.i++) {
if (_root.level.hitTest(this._x+this.xarr[this.i ], this._y-this.yarr[this.i], true)) {
this.colissionarr.push(this.i);
this.hit = true;
}
}
if (this.hit) {
this.moving(-1);
this.colltwo();
}
};
ball.prototype.colltwo = function() {
this.found = false;
for (this.l=0; this.l<(this.colissionarr.length-1); this.l++) {
if (!this.found) {
if ((this.colissionarr[this.l]-this.colissionarr [(this.l+1)])<(-1)) {
this.pointa = this.colissionarr[this.l];
this.pointb = this.colissionarr[(this.l+1)];
this.found = true;
} else {
this.pointa = this.colissionarr[0];
this.pointb = this.colissionarr[this.colissionarr.length-1] ;
}
}
}
if (this.pointa>27 && this.pointb<9) {
this.pointb += 36;
}
if (this.pointb>27 && this.pointa<9) {
this.pointa += 36;
}
this.colang = (this.pointa*10+this.pointb*10)/2;
while (this.rotation>=360) {
this.rotation -= 360;
}
while (this.rotation<0) {
this.rotation += 360;
}
while (this.colang>=360) {
this.colang -= 360;
}
while (this.colang<0) {
this.colang += 360;
}
this.diff = this.rotation-this.colang;
this.rotation -= 180+(2*this.diff);
this.moving(2);
};
ball.prototype.onEnterFrame = function() {
for (this.b=0; this.b<3; this.b++) {
if (!this.hit) {
this.moving(1);
}
this.colission();
}
};
_root.attachMovie("ball", "ball", 100);

Response to Actionscript codes here! 2006-12-21 23:09:15


At 12/21/06 11:04 PM, Disarray-yarrasiD wrote: decent pong:

Talented... :)

Response to Actionscript codes here! 2006-12-22 16:16:33


i've just dont that tutorial for swarming and its bull crap, it didnt work...Can anyone give me the actionscript to make my movie clip 'fly' to swarm my mouse?

Response to Actionscript codes here! 2006-12-22 16:18:46


Talented... :)

thanks :)

Response to Actionscript codes here! 2006-12-22 16:22:58


i need a script that will stop the instance "fist" going too far away from an instance "body" can somebody give me script please you will be mentioned in my game
ty

Response to Actionscript codes here! 2006-12-22 16:28:42


Hello, I am looking for a script to the game" Double wire"

link here :http://onemorelevel.com/games3/double-wires. swf

I really wanna learn this script and make a couple gadgets.. (noy to post but to fool around with at home) i luv this game and i wanna learn to make one like it..

Thank ou'
Justin Frost

Response to Actionscript codes here! 2006-12-22 16:41:46


hey, i was wondering if someone could script a game with me? i need someone who is uber pwnage. post back or AIM me at senorfluffypants. thanks.

Response to Actionscript codes here! 2006-12-23 09:50:15


How do you make a password system, so that when you type sumting in it takes you to a frame? I'm making a sniper game so I need it.

Response to Actionscript codes here! 2006-12-23 17:21:19


I'm looking for a code so a movieclip called VCAM will follow a movieclip entitled MAN during any movement it may perform.
I also wish to have walls, to stop me from going off of a map.

how would I do this?

I assume it would be hit tection on some walls around the map-- but would this have to be on the same layer as the player? Could it be on another?

What would the code be so when 'MAN' hits 'WALL' he cannot pass?
I also want him to move in several directions:

UP
UPLEFT
UPRIGHT
DOWN
DOWNLEFT
DOWNRIGHT

how would I do this?

Here is the code I have on my man:

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_rotation = 360;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_rotation = 180;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_rotation = -90;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation = 90;
play();
}
}

what would I add to my code so all the ways of movement, mentioned earlier, are possible?
How would I make it so he actually moves?
Hit detection?
A movieclip that 'hovers' over the top of the player, no matter what?

Response to Actionscript codes here! 2006-12-23 18:11:31


At 12/23/06 05:21 PM, Unconscious wrote: I'm looking for a code so a movieclip called VCAM will follow a movieclip entitled MAN during any movement it may perform.
I also wish to have walls, to stop me from going off of a map.

how would I do this?

I assume it would be hit tection on some walls around the map-- but would this have to be on the same layer as the player? Could it be on another?

What would the code be so when 'MAN' hits 'WALL' he cannot pass?
I also want him to move in several directions:

UP
UPLEFT
UPRIGHT
DOWN
DOWNLEFT
DOWNRIGHT

Sorry, I only konw how to do the basic all perpose movement script, but you said you wanted it so the character will stop when he hits a wall? that script is in either the first second or 279 page, sorry I couldnt be more help! ^^


how would I do this?

Here is the code I have on my man:

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_rotation = 360;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_rotation = 180;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_rotation = -90;
play();
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation = 90;
play();
}
}

what would I add to my code so all the ways of movement, mentioned earlier, are possible?
How would I make it so he actually moves?
Hit detection?
A movieclip that 'hovers' over the top of the player, no matter what?

Response to Actionscript codes here! 2006-12-23 18:58:04


Hello everybody.
I am trying to make a flash with all the codes (that can be copied) posted in this forum.
If you have any ones that you think that are really unique or great please e-mail me.
Click on the e-mail link below.

Thanks-RMC


BBS Signature

Response to Actionscript codes here! 2006-12-23 19:41:06


At 12/23/06 06:58 PM, R-M-C wrote: Hello everybody.
I am trying to make a flash with all the codes (that can be copied) posted in this forum.
If you have any ones that you think that are really unique or great please e-mail me.
Click on the e-mail link below.

Thanks-RMC

here's one:

stop();