2009年2月アーカイブ

au端末でしたら、Flash LIte1.1以降でGPSを取得ができました。

下記の記事の下部に記述方法が書いてあります。
http://thinkit.jp/article/794/1/

getURL("device:location?url=CGIのURL") //位置情報送信
getURL("device:gpsone?url=(CGIのURL)&ver=1&datum=1&unit=1&acry=0&number=0") //GPS
で取得可能でした。

fscommand("device:location?url=CGIのURL");
でも同様に可能でした。

動作確認したのは、neon(1.1ver)とW43s(2.0ver)の2端末です。

AUだけまだ3.0端末がでていませんでしたが、
今月(2009年2月)リリースされた下記の4端末に搭載されました。
・CA001
・H001
・SH001
・T001


Flash Lite Developer Challengeなるコンテストがありました。

最高賞金1000万ドルですって。。すごすぎます。
loadvaliablesでサーバサイドの結果をFlash側に反映されたタイミングを取得するサンプルを作りました。

作成したサンプルファイルはこちら→サンプルファイル

簡単に作りを説明しますと、
サーバサイドからの結果を取得、反映されるプロパティは、「result」としています。

resultはデフォルトが0でサーバサイドの結果取得(1or2)にあわせて、
「取得完了・取得失敗」の文字を表示しています。

利用したサーバサイドスクリプトは下記になります。(言語:php)
<?php

$result = 1;

//なんらかの処理

header("Content-Type:text/plain;charset:shift-jis;");
echo("result={$result}");


下記の記事面白かったです。読んでてテンション上がった。

○Flash LIte導入サイトまとめ
http://thinkit.jp/article/803/1/

FlashLite×CMSの話はうちにもよくきますし、
FlashLite×MultiMediaServerを去年初めて見たときは感動しました。

今後、記事にあるような表現は確実に増えることを実感しています。
面白いもの作りたいですねー。
ファイルアップロード機能をsoapを利用して実装しました。

Webアプリケーションで実現するには、FlashPlayer10以降になります。
FileReferenceにローカルファイルアクセスが可能なAPIが追加されています。
public function get data():ByteArray
public function load():void
public function save(data:*, name:String = null):void

下記の記事を参考にしました。
○「ローカルファイルアクセス機能」記事
http://weblogs.macromedia.com/akamijo/archives/2008/07/flash_player_10_5.html
1.×系でradioButton風なサンプル作りました。

下記からサンプル見れます。
(注)モバイルからでないと動きません。
http://maxfactory.biz/flash/sample/radio_sample.swf

作成の仕方は、以前書いた「擬似スクロール」と基本的なところは同じです。
チェックボックスのViewはMCで作成して、
ボタンはalpha0%で配置しておきます。

チェックボックスMCは、
第1フレーム:normal
第2フレーム:selected
第3フレーム:normal+focus
第4フレーム:selected+focus
のviewを作ります。

ボタンのイベントは、
on (rollOver) {
   
    tellTarget("/radio1/") {
       
        if (_root.selectedValue == 1) {
            gotoAndStop(4);
        }else {
            gotoAndStop(2);
        }
    }
}

on (rollOut) {
   
    tellTarget("/
radio1/") {
       
        if (_root.selectedValue == 1) {
            gotoAndStop(3);
        }else {
            gotoAndStop(1);
        }
    }
}

on (press) {
   
    _root.selectedValue = 1;
   
    tellTarget("/
radio1/") {
        gotoAndStop(4);
    }
   
    tellTarget("/
radio2/") {
        gotoAndStop(1);
    }
}

のようにイベントごとに見た目とcheck状態を変化させています。
各ソースの簡単な説明です。
まず、
radio1がラベル「はい」のラジオボタン
radio2がラベル「いいえ」のラジオボタン
selectedValueがチェック状態を判別するプロパティ(1:はい、2:いいえ)です。

上記のスクリプトはラベル「はい」のラジオボタンのイベントです。
ロールオーバー時にフォーカスを当てた見た目に変更
ロールアウト時にフォーカスをはずした見た目に変更
クリック時に選択時の見た目に変更し、check状態も変更しています。

radio2のイベントもほぼ同様な形でOKです。
簡単ですが説明終わりです。

CS3以降で開けるflaファイルを上げておきますー。
DLはこちらからどうぞ↓
http://maxfactory.biz/flash/sample/radioButtonSample.zip

BoxにaddChildした後に、
追加したComponentに移動までスクロールバーが移動するAnimeクラスを作成しました。

○作成したものはこんな感じ
http://maxfactory.biz/flex/sample/sample1.html


ソースは下記になります。

○Main.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:effects="*"
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
    <mx:Script>
        <![CDATA[
            import mx.controls.TextInput;
            import mx.effects.easing.Linear;
           
            private var number:uint = 1;
           
            private function addItem():void
            {
                var s:TextInput = new TextInput();
                s.text = "test" + number++;
                s.width = 80;
                s.height = 40;
                vBox.addChild(s);
            }
           
           
            private function addItemRow():void
            {
                var s:TextInput = new TextInput();
                s.text = "hoge" + number++;
                s.width = 80;
                s.height = 40;
                hBox.addChild(s);
            }
           
        ]]>
    </mx:Script>
   
    <effects:VBoxAnimateProperty id="vBoxAnimate" />
    <effects:HBoxAnimateProperty id="hBoxAnimate" />
   
    <mx:VBox>
       
        <mx:ControlBar>
            <mx:Button
                 label="縦追加"
                 click="addItem()" />
            <mx:Button
                 label="横追加"
                 click="addItemRow()" />
        </mx:ControlBar>
       
        <mx:VBox id="vBox"
            width="110" height="100" childAdd="vBoxAnimate.play(vBox)" />
       
        <mx:HBox id="hBox"
            width="110" height="100" childAdd="hBoxAnimate.play(hBox)" />
    </mx:VBox>
   
</mx:Application>


○HBoxAnimateProperty.as

package
{
    import mx.containers.HBox;
    import mx.core.UIComponent;
    import mx.effects.AnimateProperty;
    import mx.effects.easing.Linear;
    import mx.events.FlexEvent;
    
    public class HBoxAnimateProperty
    {
        public var duration:int;
        public var easingFunction:Function;
       
        private var hBox:HBox;
        private var animateProperty:AnimateProperty;
       
        public function HBoxAnimateProperty()
        {
            animateProperty = new AnimateProperty();
           
            duration = 200;
            easingFunction = Linear.easeOut;
        }
   
        public function play(target:HBox):void
        {
            hBox = target;
            var item:UIComponent = hBox.getChildren()[hBox.getChildren().length-1];
            item.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
        }
       
        private function creationCompleteHandler(e:FlexEvent):void
        {
            animateProperty.toValue = hBox.maxHorizontalScrollPosition;
            animateProperty.target = hBox;
            animateProperty.property = "horizontalScrollPosition";
            animateProperty.easingFunction = easingFunction;
            animateProperty.duration = duration;
            animateProperty.play();
        }
    }
}


VBoxAnimateProperty.as
というものも作成しましたが、 HBoxとほぼ同じなので省略。

childAddのイベントハンドラでアニメーションを開始しているのですが、
そのタイミングだと、maxHorizontalScrollPositionが追加する前の長さを返すので、
 追加したComponentがcreationCompleteしてからアニメーションを実行するようにしました。
effectはeasyFunctionだが、変更できます。
あと、duration。その他も拡張していけばOK
ソフトバンクのモバイルウィジェット製作始めてました。
まずソフトバンクの下記のサイトから、
ドキュメントやパッケージングツール、エミュレータをゲットしました。

http://creation.mb.softbank.jp/widget/index.html

まだまだHowToやサンプルソースなどないが、
下記のサイトは、わかりやすかったです。

http://www.hanatsuki.net/mobilewidget/col1_1.php

プロフィール

author:max

横浜で働いてます。Flashが好き。

■主な受賞歴
ソフトバンクモバイル株式会社主催:モバイルウィジェットコンテスト「アドビシステムズ賞」

2009年6月

  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

ウェブページ