Search code examples
actionscript-3returnstatic-functions

Return an object with an update data, that is pass in to a public static function


How can I return an object with an update data, that is pass in to a public static function?

GetDate.dayName(MyDate.setDate(1984,3))
//MyDate with new info (year, month) will be pass into GetDate.dayName


package hwang.time
{

public class MyDate
{
    public static var getYear:Number;
    public static var getMonth:Number;

    public static function setDate(year:Number, month:Number = 1):Object
    {
        getYear = year;
        getMonth = month
        verify()
        return null
    }

    private static function verify():void
    {
        //something
    }
}
}

Solution

  • public static function setDate(year:Number, month:Number = 1):MyDate
    
        {
            getYear = year;
            getMonth = month
            verify()
    
            verify()
    
            return new MyDate
        }
    

    Here's what I come up with.Thanks for helping anyway :)