forked from: 18歳だった ff: ActionScriptで生年月日から年齢を計算する簡単ロジック

by 9re forked from 18歳だった ff: ActionScriptで生年月日から年齢を計算する簡単ロジック (diff: 2)
♥0 | Line 27 | Modified 2011-02-16 17:47:35 | MIT License
play

ActionScript3 source code

/**
 * Copyright 9re ( http://wonderfl.net/user/9re )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oT2d
 */

<?xml version="1.0"?>
<!-- forked from bkzen's 18歳だった ff: ActionScriptで生年月日から年齢を計算する簡単ロジック  -->
<!-- forked from clockmaker's ActionScriptで生年月日から年齢を計算する簡単ロジック  -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<!--
超簡単に年齢を算出!
-->  
    <mx:Script>
        <![CDATA[
        import mx.controls.Alert;
        
        public function calcAge():void
        {
            var b: Date = myBirth.selectedDate, y: int = b.getFullYear(), m: int = b.getMonth(), d: int = b.getDate();
            Alert.show("18歳と"+((new Date-new Date(y+18,m,d))/86400000|0)+"日");
        }
        ]]>
    </mx:Script>
    
    <mx:Label text="あなた誕生日を入力ください" />
    <mx:DateField 
        id="myBirth" 
        selectedDate="{new Date('Feb 16 1983')}"
        yearNavigationEnabled="true"
        formatString="YYYY年MM月DD日"
        />
    <mx:Button click="calcAge()" label="計算する" />
    <mx:Button click="navigateToURL(new URLRequest('http://twitter.com/bkzen/status/24723495938'))" label="詳しくはこちら" />
    
</mx:Application>