开发者

ActionScript Encapsulating a Static Function

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜