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;
开发者_StackOverflow }
}
}
}
this i would call it like this:
var myNum:Number = NumberAdd.myNumber(2);
trace(myNum); //traces 4
what is my mistake?
package
{
public class NumberAdd
{
public static function myNumber(val:Number):Number
{
return val + 2;
}
}
}
try this
精彩评论