Be a Supporter!
Response to: Making a MC rotate to mouse angle.. Posted July 24th, 2005 in Game Development

At 7/24/05 07:16 PM, NuclearPop wrote: I saw a tut here a while back, and I can't find it now! It was where you pasted some AS into a movie clip and, whenever you moved the mmouse, not only would thhe movie clip follow but rotate yo your cursor?

What was that AS?

*Digs out 'Chasing.fla'

This is designed to work with an MC InstanceNamed 'player'. Post it on the enemy MC.

onClipEvent(load){
spd=10; //Set enemy speed
}

onClipEvent(enterFrame){
//rotate enemy
Xdiff= _parent.player._x-_x;
Ydiff= _parent.player._y-_y;
radAngle=Math.atan2(Ydiff,Xdiff);
_rotation=int ((radAngle*360/ (2*Math.PI))+90);
updateAfterEvent();

if(this.hitTest(_parent.player.centre)){
//Do attack
}else{
//Move
if(_rotation>180){
_y+= (spd*Math.cos(Math.PI/180*_rotation));
_x-= (spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-= (spd*Math.cos(Math.PI/180*_rotation));
_x+= (spd*Math.sin(Math.PI/180*_rotation));
}
}
}

If you want it to chase the mouse, use this:

onClipEvent(load){
spd=10; //Set enemy speed
}

onClipEvent(enterFrame){
//rotate enemy
Xdiff= _root._xmouse-_x;
Ydiff= _root._ymouse-_y;
radAngle= Math.atan2(Ydiff,Xdiff);
_rotation= int((radAngle*360/ (2*Math.PI))+90);
updateAfterEvent();
//Move
if(_rotation>180){
_y+= (spd*Math.cos(Math.PI/180*_rotation));
_x-= (spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-= (spd*Math.cos(Math.PI/180*_rotation));
_x+= (spd*Math.sin(Math.PI/180*_rotation));
}
}

Response to: AS: FireWorks ;) Posted July 24th, 2005 in Game Development

At 7/24/05 06:43 PM, NuclearPop wrote: Yeah, see, I'm terrible at editing actionscript, if you told me to make a sustom cursor I'd run away. :(

Heh. Just keep practicing. i never took any lessons or stuff, most of the stuff I know is learnt by the same method you're using: playing with public flas/code (and the occasional tutorial/reference to the Flash help files & AS Dictionary). So long as you're willing to learn, you're sorted.

As for the last fireworks script posted (by -liam-): I like the background and the rocket, but I think the particles should be smaller, more glittery, and have gravity take effect earlier. The gravity seems to 'pause' before it takes effect, which is not what happens with real fireworks; the particles start being affected by gravity as soon as they are expelled from the rocket. I'd analyse the code myself, but I'm a little busy with a couple of other API projects right now.

Response to: I need somebody to draw a gun for a Posted July 24th, 2005 in Game Development

Here.

I need somebody to draw a gun for a

Response to: How do I delete my own tracks...? Posted July 24th, 2005 in Audio

At 7/24/05 01:42 AM, ljcoffee wrote:
At 7/24/05 01:07 AM, Crazy_Train wrote: I wish to delete two of my own tracks...
Try emailing a mod ... You can't do it yourself ... wish you could though

Mods have no control over audio once it's in. Contact one of the admins.

Response to: Audio help Posted July 24th, 2005 in Audio

Audio Sticky - Help & Guidelines

Response to: grrr Posted July 24th, 2005 in Game Development

don't expect it to work perfectly

Response to: Hyperlink problem Posted July 24th, 2005 in Game Development

At 7/24/05 01:27 AM, jwags1 wrote: That script opens it in a new window, but i want it to open in the same window, how do i do that?

on (release) {
getURL("http://www.MYSITE.com","_self");
}

Response to: Dynamicly create text? Posted July 23rd, 2005 in Game Development

At 7/23/05 07:30 PM, jeremysfilms wrote: Is there any way to do it without using the textFormat object? Like just saying:

myText.align="center"??

Or do I need to use textFormat?

I've found that some of the textformat stuff you can get away with just stating (eg.textname.text="Radish";), but some of the stuff requires you to actually create the newTextFormat and apply it to your textbox with .setTextFormat(jhlfkksd)

I think 'align' is one of the ones you have to declare with a newTextFormat

Response to: Dynamicly create text? Posted July 23rd, 2005 in Game Development

At 7/23/05 07:24 PM, jeremysfilms wrote: How do I make the text in the text box centered?

myformat = new TextFormat();
myformat.align="center"

mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);

Response to: AS: FireWorks ;) Posted July 23rd, 2005 in Game Development

I actually posted a fireworks script in the API thread while ago... it doesn't have the rocket, but the particles are more sparkly =)
Copy/paste job:

Quick firework-style script. Click background to generate.

//Recommend 20 to 25 FPS
gravity=30;
numsparks=100;
sparksize=2;

SW=Stage.width; SH=Stage.height; f=100;
C1=new Array("0xFF0000", "0xFFFFFF", "0xFFFF00", "0xFF9900", "0xFFCC33", "0xFFFFFF")

function makespark(rd){
_root.createEmptyMovieClip("spark", -7000);
with(spark){
lineStyle(0, 0xFFFFFF, 0);
beginFill(0xFFFFFF);
moveTo(0, -rd);
curveTo(rd*1.5, 0, 0, rd);
curveTo(-rd*1.5, 0, 0, -rd);
endFill();
_visible=0;
}
}

function makeback(){
_root.createEmptyMovieClip("back", 1);
with(back){
beginFill(0x000000, 100);
moveTo(0, 0);
lineTo(SW, 0);
lineTo(SW, SH);
lineTo(0, SH);
lineTo(0, 0);
endFill();
}

back.onPress=function(){
f+= numsparks+10;
for(z=f; z<(f+numsparks); z++){
duplicateMovieClip("spark", "spark"+z, z)
with(_root["spark"+z]){
_x=_root._xmouse;
_y=_root._ymouse;
}
_root["spark"+z].vx= ((random(400)-200)/35);
_root["spark"+z].vy= ((random(200)-150)/35);

_root["spark"+z].onEnterFrame=function(){
new Color(this).setRGB(C1[random(C1.length)]);
this._x+=this.vx*0.6;
this._y+=this.vy*1;
this._alpha-=1;
down=random(gravity)/100;
this.vy+=down;
if(this._y>SH || this._alpha<0){
this.removeMovieClip();
}
}
}
}
}

makeback()
makespark(sparksize)

RESULT

Response to: Dynamicly create text? Posted July 23rd, 2005 in Game Development

MovieClip.createTextField()
Availability
Flash Player 6.

Usage
my_mc.createTextField(instanceName, depth, x, y, width, height)

Parameters
instanceName A string that identifies the instance name of the new text field.

depth A positive integer that specifies the depth of the new text field.

x An integer that specifies the x coordinate of the new text field.

y An integer that specifies the y coordinate of the new text field.

width A positive integer that specifies the width of the new text field.

height A positive integer that specifies the height of the new text field.

Returns
Nothing.

Description
Method; creates a new, empty text field as a child of the movie clip specified by my_mc. You can use createTextField() to create text fields while a SWF file plays. The text field is positioned at (x, y) with dimensions width by height. The x and y parameters are relative to the container movie clip; these parameters correspond to the _x and _y properties of the text field. The width and height parameters correspond to the _width and _height properties of the text field.

The default properties of a text field are as follows:

type = "dynamic"
border = false
background = false
password = false
multiline = false
html = false
embedFonts = false
variable = null
maxChars = null

A text field created with createTextField() receives the following default TextFormat object:

font = "Times New Roman"
size = 12
textColor = 0x000000
bold = false
italic = false
underline = false
url = ""
target = ""
align = "left"
leftMargin = 0
rightMargin = 0
indent = 0
leading = 0
bullet = false
tabStops = [] (empty array)

Example
The following example creates a text field with a width of 300, a height of 100, an x coordinate of 100, a y coordinate of 100, no border, red, and underlined text.

_root.createTextField("mytext",1,100,100,3
00,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;

myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
myformat.underline = true;

mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);

See also
TextFormat class

Response to: Newgrounds Preloader Posted July 23rd, 2005 in Game Development

If possible, make sure your first frame is clear of all else besides the preloader (especially things like images, sounds). Otherwise it may take some time for the preloader to show, and it'll already be half-loaded when it does.

Response to: making preloaders Posted July 23rd, 2005 in Game Development

AS: Preloader

Also, there are a couple more NG preloaders linked from my sig, have a look.

Response to: removeMovieClip help!!?!! Posted July 23rd, 2005 in Game Development

At 7/23/05 11:55 AM, jeremysfilms wrote: If the movieclips are both on different levels, can that effect a hitTest?

It shouldn't. Try this:

_root.onEnterFrame=function(){

if(enemy.hitTest(mc)) {
_root.mc.removeMovieClip();
_root.enemy.removeMovieClip();
}

}

Response to: AS: Variables Posted July 23rd, 2005 in Game Development

At 7/23/05 10:02 AM, -liam- wrote: Donkeys arouse me

I hope you use protection

Response to: AS: moving a character Posted July 23rd, 2005 in Game Development

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(2);
_x -= -10;
}else if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(3);
_x -= -10;
}else{
this.gotoAndStop(1);
}
}

Response to: "You Lack Discipline!" Posted July 23rd, 2005 in Audio

At 7/23/05 06:35 AM, M-A-R-C-U-S wrote: these awesome words are desperately needed by I, or furthermore, my father.
Arnold Schwarzenneger states this amazing phrase in one of his movies, and i'll be damned if i can A: find out where the fuck it's from (im guessing Kindergarten Cop?), and

Bingo!!!

B: isolate that little audio snippet so that it can be used in presentations and such....

Swf Decompiler, anyone?
MP3

At 7/23/05 08:19 AM, M-A-R-C-U-S wrote: i actually have no idea how i can USE that one little sound on its own...
and say, use it in powerpoint...

Dunno, never used Powerpoint. Flash will take mp3 or wav. If you need another format for Powerpoint, check the Audio Software: Sound Converters thread.

Response to: AS: Starfield Script Posted July 23rd, 2005 in Game Development

At 7/23/05 08:09 AM, Inglor wrote: I am teh 1337 modder!
lol = c-21;
http://img301.images..hp?image=gggg2lv.swf

Heh, that's pretty sweet. I particularly like the variable 'lol'

Response to: AS: scrolling background Posted July 23rd, 2005 in Game Development

Strangely enough:
AS: Movement - Scrolling background by DrDeath2k3

Also
AS: Movement - Basic

Response to: AS: Starfield Script Posted July 23rd, 2005 in Game Development

Hmmm, bloody BBS auto-linebreak fucks things up again.
This line in both codes (at the end of the MAKE NEW STAR section):

_root["star"+c].spd=random(speed/2)+speed/
2;

should be:

_root["star"+c].spd= random(speed/2)+speed/2;

if you get errors when copy/pasting, that'll probably be why

Response to: As: Main Posted July 23rd, 2005 in Game Development

At 7/23/05 06:35 AM, Inglor wrote: you know you don't have to ask... I don't make these to get credit for doing so, I make this to get this forum cleaner of n00b threads badly answered.

Heh. Well, you'd probably code it in a completely different way, so feel free to comment/post your own code: AS: Starfield

AS: Starfield Script Posted July 23rd, 2005 in Game Development

AS: Main

Starfield

This code uses the following:
Intervals, Functions, attachMovie, Variables, Maths, Conditions, Movement, Arrays, and a touch of API.

====================== ======================

This is a simple star field, created dynamically. Add this code to the first frame of your movie:

//Black background, 20+ FPS
var frequency=50; //new stars per second
var speed=5; //star speed
var accel=20; //star acceleration

SW=Stage.width; SH=Stage.height;
c=1000;

//Create timer function
interv = setInterval(function () {
makestar()
}, 1000/frequency);

//Function to create a new star
function makestar(){
c++; //Use for unique Instance Name and depth
if(c>2000){ c=1000; }

//MAKE NEW STAR
_root.createEmptyMovieClip("star"+c, c)
with(_root["star"+c]){
//Draw a circle (with API)
lineStyle(2, 0xFFFFFF, 100);
lineTo(0.2, 0);
//Set position, direction and alpha
_x=SW/2; _y=SH/2;
_alpha=0;
_rotation=random(360);
}
//Set speed
_root["star"+c].spd=random(speed/2)+speed/
2;

//TELL NEW STAR WHAT TO DO EACH FRAME
_root["star"+c].onEnterFrame= function(){
with(this){
//Speed it up, make it bigger
spd*=1+(_root.accel/500);
_width*= 1+(_root.accel/2500);
_height*= 1+(_root.accel/2500);
_alpha+=3;
//Move it
if(_rotation>180){
_y+=(spd*Math.cos(Math.PI/180*_rotation));
_x-=(spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-=(spd*Math.cos(Math.PI/180*_rotation));
_x+=(spd*Math.sin(Math.PI/180*_rotation));
}
//If off-screen, remove star
if(_x<0-_width || _x>SW+_width || _y>SH+_width ||_y<-_width){
this.removeMovieClip();
}
}
}
}

RESULT

====================== ======================

This is virtually the same code, but uses an attached movie rather than an API dot as the star. For this to work, you'll need to:

Right-click the MC in the library.
Select 'Linkage'
Tick the 'Export for Actionscript' box
Give it the Identifier 'star'

Add this code to the first frame of your movie:

//Black background, 20+ FPS
var frequency=50; //new stars per second
var speed=5; //star speed
var accel=20; //star acceleration

SW=Stage.width; SH=Stage.height;
c=1000;

//Create timer function
interv = setInterval(function () {
makestar()
}, 1000/frequency);

//Function to create a new star
function makestar(){
c++; //Use for unique Instance Name and depth
if(c>2000){ c=1000; }

//MAKE NEW STAR
_root.attachMovie("star", "star"+c, c)
with(_root["star"+c]){
//Set position, direction and alpha
_x=SW/2; _y=SH/2;
_alpha=0;
_rotation=random(360);
}
//Set speed
_root["star"+c].spd=random(speed/2)+speed/
2;

//TELL NEW STAR WHAT TO DO EACH FRAME
_root["star"+c].onEnterFrame= function(){
with(this){
//Speed it up, make it bigger
spd*=1+(_root.accel/500);
_width*= 1+(_root.accel/2500);
_height*= 1+(_root.accel/2500);
_alpha+=3;
//Move it
if(_rotation>180){
_y+=(spd*Math.cos(Math.PI/180*_rotation));
_x-=(spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-=(spd*Math.cos(Math.PI/180*_rotation));
_x+=(spd*Math.sin(Math.PI/180*_rotation));
}
//If off-screen, remove star
if(_x<0-_width || _x>SW+_width || _y>SH+_width ||_y<-_width){
this.removeMovieClip();
}
}
}
}

RESULT (MC was a light blue line)

====================== ======================

WHAT!?

Both of these codes basically do the same thing: they create a new star at the centre of the stage every X milliseconds, based upon the interval set.
As it is initiated, each star is assigned position, speed, alpha and rotation values.
Then, on each new frame, the star's values for alpha, size and speed are adjusted. The star is then moved based upon these settings.
Finally, when the star is out of sight, it is removed.

====================== ======================

Some interesting variations:

To spin yourself out, find this line in the code:
_alpha+=3;
And add this after it:
_rotation+=5;
RESULT

To make the 'source spot' follow the mouse, replace this line:
_x=SW/2; _y=SH/2;
with these:
_x= _root._xmouse;
_y= _root._ymouse

This looks better if you change this line:
_alpha=0;
to
_alpha=50;
RESULT

For multicoloured stars, use the first (API dot) code, and add this at the top:
cols=new Array(0xFF0000, 0xFF9900, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF66FF, 0xCC33FF)
Then change this line:
lineStyle(2, 0xFFFFFF, 100);
to this:
lineStyle(2, cols[random(cols.length)], 100);
RESULT

====================== ======================

Basically, play with bits of the code to see what happens when you adjust values. This is quite a good sample for trying out various different aspects of AS. Have fun =)

Response to: As: Main Posted July 23rd, 2005 in Game Development

At 7/23/05 06:19 AM, Inglor wrote: I will, don't worry, I just don't feel like making an AS thread now

Do you mind if I take the starfield?

Response to: liljim help! Posted July 22nd, 2005 in Where is / How to?

At 7/22/05 07:33 PM, Glaiel_Gamer wrote: does liljimn visit the audo form?

Occasionally. He's just as likely to see your post here, though. But, you really should use email liljim[@]newgrounds.com

Response to: Wi/Ht Members Vs. Mods Posted July 22nd, 2005 in Where is / How to?

Congrats -Gooch-, I've thought you deserved this for quite a while.

At 7/22/05 05:38 AM, Alkador wrote: I think this place has changed so much in the past three to four months.

Yeah. Without the lists, D0GMA &co to keep me amused in here, I'm sorry to say I no longer count myself as a Wi/Ht regular. I spend a reasonable amount of time in the Flash forum, but I guess the new baby and other RL obligations are severely limiting my NG time.

Good to see that the legacy continues, though. I just wish the lists were still running.

Response to: Dynamic image resizing Posted July 22nd, 2005 in Game Development

That's pretty funky.

Here's a challenge: make it so that it will loadMovie external images from the same folder as the fla, get their dimensions, and adjust accordingly (the 740x590 thing is limiting the code).

I don't even know if it's possible, but it would be a great thing for websites.

Response to: AS: While Posted July 22nd, 2005 in Game Development

This is going waaaaaaaaaay off-topic, but it's a compatibility issue for me; pretty much EVERY program (apart from maybe 2) is compatible with Windows; whereas the number of programs that will work with a MAC is limited. I have to admit, I've never actually tried one, but I've heard plenty of complaints about (lack of) application compatibility, and that's enough to put me off.

As for virus protection and crashing, my PC has crashed twice (not irrepairably) in the three years since I got XP, and I have enough know-how to never get virii on my machine. The kind of PC users who let Windows get to the stage where it dies through infection or bad organisation would probably kill a MAC in about 3 hours.

Response to: Today I begin my 2 day journey... Posted July 22nd, 2005 in General

At 7/22/05 06:01 PM, -Frank- wrote: Today I'm going to go see The Aquabats in concert for the 4th time in San Diego. Then tomorrow... I'm going to go see The Aquabats in concert for the 5th time in Hollywood. What does this all equate to? Well, the answer is two super rad days of SERIOUS AWESOMENESS!

You have a problem. See a psychiatrist.

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 04:39 PM, Glaiel_Gamer wrote: or get a mac.

HAHAHAHAHAHAHAHAHAHAAAAAAAA
HAHAHHAAAAAA
HAHAHAHAAAhAHAHAHhahahaha
hahahah
hahaha
haaaaaaaaaa
HAHAHAHAHAHAHAHAAAAAAA
ha
haha
ha

no.