Flashでのオーバーレイサイト

何気なくperfumeのサイトを覗いたら先日のオーバーレイの技術が使われていたのでちょびっと紹介。
perfumeのサイト

ライブラリはむらけんさんので、それを改変しています。
JavaScriptのソースを読むとわかると思いますが、だいたい以下の流れになっています。

addLoadEvent(initoverLayFlash);
↓
function initoverLayFlash(){
    showFlash(this);
}function showFlash(objLink){
    var file = "/perfume/swf/overlay.swf";
    ここの部分がカスタイマイズされています。
    オーバーレイ処理
}

っとなっています。
サイト表示時に、いきなりFlashで遊びをいれるのも面白いですね。
参考リンク

郵便番号から住所補助

郵便番号から住所補助をしてくれるFlexプログラムを作ってみました。
こんな感じ
http://moeten.info/flex/20080812_yuubinTest/bin-release/main.html

入力補助ボタンを押すと住所を補助してくれます。
簡単な説明
まずはこちら。

こちらのURL(http://zip.cgis.biz/xml/zip.php)にzn=[郵便番号]を付加してGETで送信するとxmlで結果が返ってきます。

http://zip.cgis.biz/xml/zip.php?zn=1000006

結果xmlはこんな感じ

<?xml version="1.0" encoding="utf-8" ?>
<ZIP_result>
  <result name="ZipSearchXML" />
  <result version="1.01" />
  <result request_url="http%3A%2F%2Fzip.cgis.biz%2Fxml%2Fzip.php%3F%26zn%3D1000006" />
  <result request_zip_num="1000006" />
  <result request_zip_version="none" />
  <result result_code="1" />
  <result result_zip_num="1000006" />
  <result result_zip_version="0" />
  <result result_values_count="1" />
<ADDRESS_value>
  <value state_kana="トウキョウト" />
  <value city_kana="チヨダク" />
  <value address_kana="ユウラクチョウ" />
  <value company_kana="none" />
  <value state="東京都" />
  <value city="千代田区" />
  <value address="有楽町" />
  <value company="none" />
</ADDRESS_value>
</ZIP_result>

また、Flash特有のクロスドメイン問題があるのでPHPなどでプロキシしてあげます。

http://moeten.info/flex/20080502_twitterAir/myproxy.php?u=http://zip.cgis.biz/xml/zip.php

あと、都道府県のComboBoxの指定方法なんですが、うまくいかなかったので、for文で回して指定しました。

//コンボボックスの指定
tidBox.selectedIndex= getTid( hts.lastResult.ADDRESS_value.value.@state ) ;
//都道府県からコンボボックスを指定
//ここなんとか簡単にしたい。selectedItemとかgetItemIndexかなぁ
private function getTid(todouhuken:String):int{
    for( var i:int = 0; i < tidArr.length ; i ++ ){
        if( tidArr[i].label == todouhuken )return i;
    }
    return -1;
}

ちょびっと便利なAPIの紹介でした。

今日気になったページ

米Adobe、「Flash Player 10」のリリース候補版を公開
Flash Player 10が標準となる次期も近い!?
Animating properties using the AnimateProperties class in Flex and Flash Player 10
Flash10ではAnimatePropertiesというクラスで複数の値をTweenできるっぽい
Getting Started with Adobe AIR on Linux (Video)
LinuxでのAIR対応状況。ビデオはこちら
WiiFlash 0.4.2 release with Balance Board Support !
バランスボード対応!
時間を節約してくれるPhotoshopのアクション400選『400+ Time Saving Photoshop Actions』