Karl, a function "returns" something if you include a line "return
value" at the end of the function...

For example, if you had a function that returned a random number below
100:

function giveMeARandomNumberBelow100():Number
{
        var myRandomNumberBelow100:Number = Math.random() * 100;
        return myRandomNumberBelow100;
}


Pointless function of course, but you get the idea?

Barry.


-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: Tuesday, 14 July 2009 4:30 p.m.
To: Flash Coders List
Subject: Re: [Flashcoders] To Void or not to void?? That is my
question..

Thanks for the quick response Taka,

So what contitutes a return?

I have used the :Void on functions that had a gotoAndPlay() inside it  
and it didnt work.
But if I removed the :Void, it did!?!


Karl


On Jul 13, 2009, at 11:18 PM, Taka Kojima wrote:

> :Void is AS2, and :void is AS3
>
> The definition of void is "nothingness: the state of nonexistence"...
>
> The syntax of functionName():void{} simply states that the function  
> returns
> nothing... i.e. there is no return at the end of the function.
>
> Although specifying a :void return type is not necessary in AS3, it is
> considered best practice to include it. I believe it will generate  
> warnings
> if you don't.
>
> In AS2, it really doesn't matter if you do :Void after functions.
>
> The reason this syntax exists is to make it easy for compilers to  
> easily
> identify problems in regards to object types, i.e. if you're trying  
> to use
> the return value of a function as a MovieClip when it should really  
> be an
> Array, or void. It also makes it easier for you to see what type of  
> value
> the function is returning just by looking at the top of the function
> definition.
>
> - Taka
>
> On Mon, Jul 13, 2009 at 9:07 PM, Karl DeSaulniers  
> <k...@designdrumm.com>wrote:
>
>> Using AS2.
>> When is it best to use the :Void ? and what is the difference  
>> between that
>> and :void ?
>> I have a somewhat understanding of what each are,
>> I am asking more to "you" (The List) as a programers, what is the  
>> best case
>> scenarios to use these things?
>> What are the advantages and why use them if say, your function works
>> without them?
>> I know that the Void is a Boolean, but I also know you cant use it  
>> when the
>> statement returns something.
>> Does this "return" include any of the basics like gotoAndPlay? or  
>> does it
>> literally mean a return(); ???
>>
>> Thanks for any clarification anyone can give me.
>>
>> Best,
>>
>>
>> Karl DeSaulniers
>> Design Drumm
>> http://designdrumm.com
>>
>> _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to