In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 1桁の月や日を0Xの形に

100で割る→1桁なら0.0X、2桁なら0.XXになる
→substr()で下2桁を取得。
Get Adobe Flash player
by Nicolas 11 Feb 2011

    Talk

    Nicolas at 11 Feb 2011 11:04
    この方法だと10、20、30のときに0が切り捨てられる関係で「.1」「.2」「.3」になってしまいます…
    Embed
/**
 * Copyright Nicolas ( http://wonderfl.net/user/Nicolas )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eHbb
 */

// forked from zahir's 1桁の月や日を0Xの形に
package {
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var d:Date = new Date();
            var month:String = String( (d.getMonth() + 1) / 100 ).substr(-2);
            var date:String = String( d.getDate() / 100 ).substr(-2);
            var full:String = String(d.fullYear) + month + date;
            (addChild( new TextField() ) as TextField).appendText( full );
        }
        //private function o2t( str:String ):String
        //{
        //        return str.length < 2 ? "0" + str : str;
        //}
    }
}