読者です 読者をやめる 読者になる 読者になる

ハピバあぷり

簡単にハピバアプリを作ってみましたー
スピナーで名前を選んで、それぞれの誕生日メッセージを再生させることができまっす。

※明日くらいにはAndroidMarketにはhappyBirthDayAppで検索すれば出るかと思います。
ってことっでソースコードでーっすっ

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" title="HappyBirthDayApp"
        xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="view1_creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;
            import spark.events.IndexChangeEvent;
            protected function image_clickHandler(event:MouseEvent):void
            {
                if( nameSound.isPlaying || messageSound.isPlaying ){
                    nameSound.stop();
                    messageSound.stop();
                    image.alpha = 0.5;
                    return ;
                }
                myFilter.play();
                nameSound.play([this]);
            }
            private var nameArr:Array = new Array(
                'abe',
                'akiyama',
                'andou',
                'aoki',
                'arai',
                'araki',
                'asano',
                'azuma',
                'baba',
                'chiba',
                'endo',
                'goto',
                'hagiwara',
                'hamada',
                'hara',
                'harada',
                'hasegawa',
                'hashimoto',
                'hattori',
                'hayakawa',
                'hayashi',
                'higuchi',
                'hirai',
                'hirano',
                'hirata',
                'hirose',
                'honda',
                'honnma',
                'hori',
                'hoshino',
                'hujii',
                'hujimoto',
                'hujita',
                'hujiwara',
                'hukuda',
                'hukui',
                'hukusima',
                'hurukawa',
                'ichikawa',
                'igarashi',
                'iida',
                'ikeda',
                'imai',
                'inoue',
                'ishibashi',
                'ishihara',
                'isida',
                'isii',
                'isikawa',
                'ito',
                'iwamoto',
                'iwasaki',
                'iwata',
                'kamata',
                'kaneko',
                'kannno',
                'katayama',
                'kato',
                'kawaguchi',
                'kawakami',
                'kawamura',
                'kawasaki',
                'kikuchi',
                'kimura',
                'kinoshita',
                'kitamura',
                'kobayashi',
                'koike',
                'kojima',
                'komatsu',
                'kondou',
                'konishi',
                'kouno',
                'koyama',
                'kubo',
                'kubota',
                'kudou',
                'kumagai',
                'kurihara',
                'kuroda',
                'kuwahara',
                'maeda',
                'maruyama',
                'masuda',
                'matsubara',
                'matsuda',
                'matsui',
                'matsumoto',
                'matsumura',
                'matsuo',
                'matsuoka',
                'matsushita',
                'matsuura',
                'minami',
                'miura',
                'miyake',
                'miyamoto',
                'miyata',
                'miyazaki',
                'mizuno',
                'mochiduki',
                'mori',
                'morimoto',
                'morita',
                'murakami',
                'murata',
                'nagai',
                'nagata',
                'naitou',
                'nakagawa',
                'nakajima',
                'nakamura',
                'nakanishi',
                'nakano',
                'nakata',
                'nakayama',
                'narita',
                'nishida',
                'nishikawa',
                'nishimura',
                'nishiyama',
                'noda',
                'noguchi',
                'nomura',
                'oda',
                'ogawa',
                'oka',
                'okada',
                'okamoto',
                'okazaki',
                'okumura',
                'ono',
                'oohashi',
                'ooishi',
                'ookubo',
                'oomori',
                'oonishi',
                'oono',
                'ooshima',
                'oota',
                'ootani',
                'ootsuka',
                'ozaki',
                'saito',
                'sakai',
                'sakamoto 1',
                'sakamoto 2',
                'sakamoto 3',
                'sakamoto',
                'sakurai',
                'sano',
                'sasaki',
                'sato',
                'sawada',
                'seki',
                'shimada',
                'shimizu',
                'shinohara',
                'sibata',
                'sudou',
                'sugawara',
                'sugimoto',
                'sugiyama',
                'suzuki',
                'taguchi',
                'takada',
                'takagi',
                'takahashi',
                'takano',
                'takayama',
                'takeda',
                'takeuchi',
                'tamura',
                'tanabe',
                'tanaka',
                'taniguchi',
                'tsuchiya',
                'tsuji',
                'uchida',
                'ueda',
                'ueno',
                'wada',
                'watabe',
                'watanabe',
                'yamada',
                'yamaguchi',
                'yamamoto',
                'yamanaka',
                'yamashita',
                'yamauchi',
                'yamazaki',
                'yano',
                'yasuda',
                'yokota',
                'yokoyama',
                'yoshida',
                'yoshikawa',
                'yoshimura',
                'yoshioka'
                );
            [Bindable]private var ac:ArrayCollection = new ArrayCollection();
            protected function dropdownlist1_changeHandler(event:IndexChangeEvent):void
            {
                nameSound.source = "assets/" + nameArr[ ddl.selectedIndex ] + ".mp3";
            }
            protected function view1_creationCompleteHandler(event:FlexEvent):void
            {
                var len:int = nameArr.length;
                for( var i:int = 0 ; i < len ; i ++ ){
                    ac.addItem({"name":nameArr[i]});
                }
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- 非ビジュアルエレメント (サービス、値オブジェクトなど) をここに配置 -->
        <mx:SoundEffect  id="nameSound" source="@Embed('assets/sakamoto.mp3')" useDuration="false" effectEnd="{messageSound.play([this])}" startTime="100" volumeFrom="0.5" volumeTo="0.5"/>
        <mx:SoundEffect  id="messageSound" source="@Embed('assets/birthday4.mp3')" useDuration="false" startTime="600" volumeFrom="0.5" volumeTo="0.5" />
        <s:DropShadowFilter id="dsf" blurX="8" blurY="8" distance="0"/>
        <s:GlowFilter id="gf" blurX="4" blurY="4" strength="10" color="0xffffff" />
        <s:Parallel target="{image}" id="myFilter" >
            <s:Fade alphaFrom="0.5" alphaTo="1"/>
            <s:AnimateFilter bitmapFilter="{new spark.filters.DropShadowFilter()}">
                <s:SimpleMotionPath property="color" valueFrom="0" valueTo="0x000000"/>
                <s:SimpleMotionPath property="alpha" valueFrom="1" valueTo="0"/>
                <s:SimpleMotionPath property="distance" valueFrom="0" valueTo="0"/>
                <s:SimpleMotionPath property="blurX" valueFrom="0" valueTo="30"/>
                <s:SimpleMotionPath property="blurY" valueFrom="0" valueTo="30"/>
            </s:AnimateFilter>
        </s:Parallel>
    </fx:Declarations>
    <s:Image id="image" source="@Embed('assets/image.png')" width="100%" height="100%" alpha="0.4"
             verticalCenter="0" horizontalCenter="0" click="image_clickHandler(event)"    filters="{[gf,dsf]}" />
    <s:SpinnerListContainer id="sp" bottom="40" horizontalCenter="0" alpha="0.8">
    <s:SpinnerList id="ddl" dataProvider="{ac}" labelField="name" change="dropdownlist1_changeHandler(event)"
                    wrapElements="true" width="200" height="200"    />
    </s:SpinnerListContainer>
    <s:Image id="btn" source="@Embed('assets/btn.png')" x="{sp.x+sp.width-30}" y="{sp.y + sp.height/2 - 100}" width="80" click="image_clickHandler(event)"/>
</s:View>