00:00
00:00
Newgrounds Background Image Theme

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

AS: Functions

9,730 Views | 34 Replies
New Topic Respond to this Topic

Response to AS: Functions 2007-06-18 16:05:44


What are all the different types of returntypes? And what is a returntype/ return returntype?

Response to AS: Functions 2008-05-29 09:32:32


Is it possible to define a function on _root, and then refer to it on a movieClip?

Because I have a code to fade out music:

function fadeOut(sound:String,frames:Number,vol:Number):Void{
	vols = vol
	onEnterFrame = function(){
	if(vol>0){
	vol -= (vols/frames);
	}
_root[sound].setVolume(vol);
if(vol == 0){
	_root[sound].stop();
}
	}
}

music=new Sound();
music.attachSound("song");
music.start(0,0);
fadeOut("music",500,100);

The layout of this being: fadeOut(path,number of frames taken to fade out, volume faded out from);

Of course, I will need to run this code from lots of movieClips, is this possible? I assume it is, but I just want to check.


BBS Signature

Response to AS: Functions 2008-05-29 10:05:08


At 5/29/08 09:32 AM, Hoeloe wrote: Is it possible to define a function on _root, and then refer to it on a movieClip?

Yes. Just try actually testing it out. :)


They used to call me souled...

Response to AS: Functions 2008-05-29 10:19:51


At 5/29/08 10:05 AM, souled wrote:
At 5/29/08 09:32 AM, Hoeloe wrote: Is it possible to define a function on _root, and then refer to it on a movieClip?
Yes. Just try actually testing it out. :)

I did. Didn't work D:

Tried:
fadeOut("mus",500,100);
fadeOut("_root.mus",500,100);
_root.fadeOut("_root.mus",500,100);
fadeOut("mus",500,100);

None worked. I'll try again.


BBS Signature

Response to AS: Functions 2008-05-29 10:21:45


At 5/29/08 10:19 AM, Hoeloe wrote:
At 5/29/08 10:05 AM, souled wrote:
At 5/29/08 09:32 AM, Hoeloe wrote: Is it possible to define a function on _root, and then refer to it on a movieClip?
Yes. Just try actually testing it out. :)
I did. Didn't work D:

Tried:
fadeOut("mus",500,100);
fadeOut("_root.mus",500,100);
_root.fadeOut("_root.mus",500,100);
_root.fadeOut("mus",500,100);

None worked. I'll try again.

Hold on: _root.fadeOut("mus",500,100); works now.

This is my first time using these function things so I'm a little shaky on them, I think I'm getting the hang of it now though.


BBS Signature