views:

18

answers:

1

i would simply like to encapsulate a function in it's own .as file, but i can't quite get it.

package
{
public class NumberAdd
    {
    public function NumberAdd()
        {
        public static function myNumber(val:Number):Number
            {
            return val + 2;
            }
        }
    }
}

this i would call it like this:

var myNum:Number = NumberAdd.myNumber(2);
trace(myNum); //traces 4

what is my mistake?

+1  A: 
package
{
    public class NumberAdd
    {
       public static function myNumber(val:Number):Number
       {
           return val + 2;
       }
    }
}

try this

antpaw
ah there's no constructor, of course. thanks :)
TheDarkInI1978