PDA

View Full Version : What does :void do?


Lou Chou
01-31-2010, 07:30 PM
private function init():void

Hi,

I've been working with this property for a while, but I still don't know when to use it, and what exactly it does. Could anyone tell me? :confused:

ASWC
01-31-2010, 08:21 PM
it tells the compiler that the function will not return a value.

timmetoe
02-01-2010, 07:33 AM
What ASWC said is correct. I'll go deeper into this subject.

You can use some functions to return values, or you can use them just to execute script.

This is an example without returning anything

private function init():void {
traceSomething();
}

private function traceSomething():void {
trace("Hai");
}


Now I AM returning a value

private function init():void {
trace(getText());
}

private function getText() {
return("Hai");
}


Both codes do the same, although the first script actually traces "Hai". The other function sends "Hai" as a string to the caller which is the trace

Lou Chou
02-01-2010, 10:36 AM
Thank you very much for the information, guys. Especially you, timmetoe, for the in-depth explanation. :)

timmetoe
02-01-2010, 12:15 PM
No problem :D

the binary
02-01-2010, 04:03 PM
to be accurate the second method should also have a return-type.. ;)


private function init():void {
trace(getText());
}

private function getText(): String {
return "Hai";
}

timmetoe
02-02-2010, 06:36 AM
Oh yeah I forgot :$

Lou Chou
02-03-2010, 11:36 AM
to be accurate the second method should also have a return-type.. ;)


private function init():void {
trace(getText());
}

private function getText(): String {
return "Hai";
}


What is a return-type? What does it do?

Jeez, I feel like I should know this stuff... :-(