2008年1月アーカイブ
Movable Typeを4.1にアップデートした。
今回の新機能で注目すべきなのは、何といってもカスタムフィールド。
待ちに待っていた標準機能。
フィールドを自分なりにカスタムするには、今まではrightfieldかcustomfieldsなどを使うしかなかったが、これが標準装備されたことになる。
使い勝手もなかなかよさそうなので、後日ポキールを復活させる予定。
FlashからXMLやphpなどのデータを取得する場合、おなじみクロスドメインが必要。
書き方はこんな感じ
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy >
<allow-access-from domain="*.yourflashpage.co.jp" secure="false"/>
</cross-domain-policy>
普通のクロスドメインと違うところは、
secure="false"
が必要だという点。
O'REILLY出版「Mind Hacks」を読んでいる。URLがたくさん出てくるので、
http://www.oreilly.co.jp/books/4873112710/links.html
から引用。さらに自分用にカスタムしていく予定。
- http://www.nytimes.com/2003/06/22/magazine/22SAVANT.html
- http://www.cognitiveliberty.org/neuro/TMS_NYT.html
- http://www.csicop.org/si/9903/ten-percent-myth.html
- http://www.snopes.com/science/stats/10percnt.htm
- http://faculty.washington.edu/chudler/tenper.html
- http://www.brainconnection.com/topics/?main=fa/brain-myth
- http://www.med.harvard.edu/AANLIB/home.html
- http://www.msu.edu/~brains/humanatlas
- http://braininfo.rprc.washington.edu/mainmenu.html
- http://brainmuseum.org
- http://www.brainvoyager.com
- http://www.ncbi.nlm.nih.gov/books/bv.fcgi?call=bv.View..ShowSection&rid=mcb.chapter.6074
- http://www.foresight.gov.uk/cognitive.html
- http://members.aol.com/Bio50/LecNotes/lecnot11.html
- http://www.thebrain.mcgill.ca/flash/index_a.html
- http://www.thebrain.mcgill.ca/flash/a/a_01/a_01_m/a_01_m_fon/a_01_m_fon.html
- http://www.ninds.nih.gov/health_and_medical/pubs/NINDS_Neuron.htm
1章 脳の構造
[Hack #1] 脳のはたらきを外から調べる
[Hack #2] EEG
[Hack #5] TMS:脳内の電気的活動を人為的に操作する
[Hack #6] fMRI:最先端の映像化技術
[Hack #7] 中枢神経系
[Hack #9] ニューロン
[Hack #12] 感覚性ホムンクルスを作ってみる
- http://www.exploratorium.edu/snacks/peripheral_vision.html
- http://psy.ucsd.edu/~sanstis/SABlur.html
- http://hyperphysics.phy-astr.gsu.edu/hbase/hph.html
- http://hyperphysics.phy-astr.gsu.edu/hbase/vision/rodcone.html
- http://white.stanford.edu/~brian/numbers/node1.html
- http://webvision.med.utah.edu/facts.html
- http://www.poynterextra.org/eyetrack2004/
- http://ilab.usc.edu/bu
- http://www.personal.psu.edu/users/e/l/elm173/schlwork/semester3/psych/complete.htm
- http://serendip.brynmawr.edu/bb/blindspot
- http://www.exploratorium.edu/snacks/cheshire_cat.html
- http://serendip.brynmawr.edu/bb/blindspot1.html
- http://gandalf.psych.umn.edu/~kersten/kersten-lab/images/ball-in-a-box.mov
- http://gandalf.psych.umn.edu/~kersten/kersten-lab/demos/BallInaBox.mov
- http://www.kyb.tue.mpg.de/links/demo.html
- http://gandalf.psych.umn.edu/~kersten/kersten-lab
- http://gandalf.psych.umn.edu/~kersten/kersten-lab/images/kersten-shadow-cine.mov
- http://web.mit.edu/persci/people/adelson/checkershadow_illusion.html
- http://www.michaelbach.de/ot/lum_adelson_check_shadow
- http://www.biols.susx.ac.uk/home/George_Mather/Motion/MAE.HTML
- http://www.at-bristol.org.uk/Optical/AfterEffects_main.htm
- http://www.naturalhighs.net/waterfalls/illusion.htm
- http://psylux.psych.tu-dresden.de/i1/kaw/diverses%20Material/www.illusionworks.com/html/motion_aftereffect.html
- http://www.psych.purdue.edu/~coglab/VisLab/ApparentMotion/AM.html
- http://www.cs.tufts.edu/~kreisman/phi/index.html
- http://ase.tufts.edu/cogstud/papers/multdrft.htm
- http://epmalab.uoregon.edu/writings/Chapter%205%20summary.pdf
- http://gregegan.customer.netspace.net.au/BIBLIOGRAPHY/Online.html
- http://www.michaelbach.de/ot/mot_flashlag1
- http://nba.uth.tmc.edu/homepage/eagleman/flashlag
- http://nba.uth.tmc.edu/homepage/eagleman/flashlag/r1.html
- http://fisio.icb.usp.br/~vinicius/Public_pdf/Baldo_Ranvaud_Morya.pdf
- http://psy.ucsd.edu/~sanstis/Foot.html
- http://www.michaelbach.de/ot/mot_feet_lin
- http://psy.ucsd.edu/~sanstis/SAPub.html
- http://psy.ucsd.edu~sanstis/PDFs/YorkChapter.pdf
- http://www.ritsumei.ac.jp/~akitaoka/index-e.html
- http://viperlib.york.ac.uk/Pimages/Lightness-Brightness/Shading/8cycles.DtoL.CW.jpg
- http://www.ritsumei.ac.jp/~akitaoka/index-j.html
- http://web.sfn.org
- http://mathworld.wolfram.com/OuchiIllusion.html
- http://www.uwm.edu/People/johnchay/mrp.htm
- http://www.sparknotes.com/psychology/cognitive/perception/section1.html
2章 視覚
[Hack #14] 解像度
[Hack #15] 能動的な視覚
[Hack #16] 盲点を探す
[Hack #20] 平面に奥行きを見る
[Hack #21] 光源は動かない
[Hack #22] 三次元認識
[Hack #23] 明るさと輝度
[Hack #24] プルフリッヒ効果
[Hack #25] 動かないものが動く
[Hack #26] 順応
[Hack #27] 動かないものを動かす
[Hack #28] 閃光遅延現象
[Hack #29] 足踏み錯覚
[Hack #30] 蛇の回転
[Hack #31] 想像の世界
[Hack #33] 役立つノイズ
- http://ruccs.rutgers.edu/finstlab/demos.htm
- http://ruccs.rutgers.edu/finstlab/mot.mov
- http://ruccs.rutgers.edu/finstlab/mot-occ-occlusion.mov
- http://ruccs.rutgers.edu/finstlab/mot-occ-virtocc.mov
- http://ruccs.rutgers.edu/finstlab/mot-occ-implosion.mov
- http://ruccs.rutgers.edu/finstlab/ZPPublications.htm
- http://www.mindhacks.com/book/44/changeblindness.gif
- http://nivea.psycho.univ-paris5.fr/ASSChtml/couple.gif
- http://nivea.psycho.univ-paris5.fr/ASSChtml/dottedline.gif
- http://viscog.beckman.uiuc.edu/djs_lab/demos.html
- http://nivea.psycho.univ-paris5.fr/ASSChtml/ASSC.html
- http://viscog.beckman.uiuc.edu/media/mindhacks.html
- http://viscog.beckman.uiuc.edu/reprints/index.php
- http://eis.bris.ac.uk/~psmfed/papers/np.html
- http://www.psych.utoronto.ca/~hasher/abstracts/may_95.htm
- http://www.l.u-tokyo.ac.jp/AandC/HLV/DataBase/NP/intro.html
- http://www.bcs.rochester.edu/people/daphne/visual.html
- http://www.bootstrap.org/augdocs/friedewald030402/augmentinghumanintellect/ahi62index.html
3章 注意
[Hack #35] サビタイジング
[Hack #36] 物体の追跡
[Hack #37] 無意識の注意
[Hack #38] 後ろは振り返らない
[Hack #39] 注意の瞬き
[Hack #40] 変化盲
[Hack #41] 不注意による盲目
[Hack #42] オオカミ少年は信じてもらえない
[Hack #43] テレビゲームによる訓練
- http://www.mindhacks.com/book/44/24Hz.mp3
- http://www.mindhacks.com/book/44/48Hz.mp3
- http://www.mindhacks.com/book/44/96Hz.mp3
- http://physics.mtsu.edu/~wmr/julianna.html
- http://www.umaine.edu/visualperception/summer
- http://www.design.kyushu-u.ac.jp/~ynhome/JPN/Demo/illusions2nd.html
- http://133.5.113.80/~ynhome/JPN/Demo/2nd/03.html
- http://www.hei.org/research/depts/aip/audiodemos.htm
- http://www.hei.org/research/depts/aip/increase_channels.mp3
- http://www.biols.susx.ac.uk/home/Chris_Darwin/SWS
- http://www.catb.org/~esr/jargon/html/F/frobnicate.html
- http://www.catb.org/~esr/jargon/index.html
- http://psy.ucsd.edu/chip/pdf/Synaesth_JCS.pdf
- http://www.stanford.edu/class/linguist34/Unit_08/blackberry.htm
- http://www.wired.com/wired/archive/5.06/es_namemachine.html
- http://www.mrc-cbu.cam.ac.uk/personal/matt.davis/Cmabrigde
- http://cognitrn.psych.indiana.edu/rgoldsto/cogsci/Feldman.pdf
4章 聴覚と言語
[Hack #44] 「タイミング」に敏感な聴覚
[Hack #45] 音源の位置の特定
[Hack #46] 音の高さ
[Hack #48] ランダムなパターンから意味を読み取る
[Hack #49] 言語の理解
[Hack #50] 「音」の持つ意味
[Hack #51] フレーズとバッファ
[Hack #52] エラーに強い並列処理
- http://psychclassics.yorku.ca/Stroop
- http://faculty.washington.edu/chudler/java/ready.html
- http://faculty.washington.edu/chudler/java/ready3.html
- http://faculty.washington.edu/chudler/neurok.html
- http://www.media.uio.no/personer/arntm/McGurk_english.html
- http://ccms.ntu.edu.tw/~karchung/Phonetics%20II%20page%20seventeen.htm
5章 感覚どうしの関係
[Hack #53] 視覚と聴覚の連携
[Hack #55] ストループ効果
[Hack #56] 方向への反応
[Hack #57] 複数の感覚情報の組み合わせ
[Hack #59] 目で聴く(マガーク効果)
[Hack #61] 2つの声の聞き分け
- http://perception.st-and.ac.uk/hemispheric/explanation.html
- http://www.michaelparker.com
- http://perception.st-and.ac.uk
- http://web.archive.org/web/20040214164445/http://www.btinternet.com/~neuronaut/webtwo_features_leftbrain.html
- http://www.abc.net.au/rn/science/mind/stories/s1137394.htm
- http://faculty.washington.edu/chudler/split.html
- http://members.aol.com/sakrug/dualbrain.html
6章 運動
[Hack #69] 右脳と左脳
- http://www.oakland.edu/enp
- http://ams.allenpress.com/pdfserv/i1520-0477-080-07-1385.pdf
- http://bmj.bmjjournals.com/cgi/reprint/327/7417/741
- http://www.cut-the-knot.org/hall.shtml
7章 推論
[Hack #70] 人間は数字が苦手
[Hack #71] 確率より頻度
[Hack #72] 論理的思考
[Hack #74] 現状維持のバイアス
- http://tepserver.ucsd.edu:16080/~jlevin/gp
- http://psy.ed.asu.edu/~classics/Wertheimer/Forms/forms.htm
- http://psy.ucsd.edu/chip/illu_mot_capt_grpng.html
- http://tepserver.ucsd.edu/~jlevin/gp/time-example-common-fate
- http://www.biols.susx.ac.uk/home/George_Mather/Motion/KDE.HTML
- http://tepserver.ucsd.edu:16080/~jlevin/gp
- http://www.lifesci.sussex.ac.uk/home/George_Mather/Motion/BM.HTML
- http://www.at-bristol.org.uk/Optical/DancingLights_main.htm
- http://www.bml.psy.ruhr-uni-bochum.de/Demos/BMLwalker.html
- http://www.kyb.tuebingen.mpg.de/bu/demo/chimericwalker
- http://www.lifesci.sussex.ac.uk/home/George_Mather/Motion/index.html
- http://www.perceptionweb.com/perc0303/p5010.pdf
- http://research.yale.edu/perception/animacy/HS-Blocks-Flash.mov
- http://research.yale.edu/perception/animacy/HS-Darts-Flash.mov
- http://en.wikipedia.org/wiki/Hanlon's_Razor
- http://web.archive.org/web/20040226172716/http://www.carleton.ca/~warrent/210/michotte/michotte.html
- http://cogweb.ucla.edu/Discourse/Narrative/michotte-demo.swf
- http://research.yale.edu/perception/causality/temporalGap.mov
- http://pantheon.yale.edu/~bs265/demos/causality.html
8章 構造を知る
[Hack #75] ゲシュタルト原理
[Hack #76] 共通運命の原理
[Hack #77] 「人間」の認知
[Hack #78] 「生命」の認知
[Hack #79] 因果関係の認知
[Hack #80] 「自分の意志」の認知
- http://www.psychologicalscience.org/teaching/tips/tips_0403.html
- http://www.search-engine-lists.com/marktwain/unconscious-plagiarism.html
- http://www.keeslau.com/TomWaitsSupplement/Lyrics/common.htm
- http://www.imdb.com/title/tt0209144
- http://eleganthack.com/blueprint/sample.php
9章 記憶
[Hack #81] プライミング
[Hack #82] サブリミナル効果
[Hack #83] 「見覚えがある」という感覚
[Hack #84] 記憶の出所
[Hack #85] 偽物の記憶
[Hack #86] 文脈干渉効果
[Hack #87] 記憶を助けるコンテキスト
[Hack #89] 道筋を使った記憶術
[Hack #92] コーヒーの味はカップで変わる?
- http://www.test.org.uk
- http://www.morguefile.com
- http://www.ecs.soton.ac.uk/~harnad/Papers/Py104/pullum.learn.html
- http://www.emotionsrevealed.com
- http://www.neuropsychologycentral.com/interface/content/resources/page_material/...
- http://www.neuropsychologycentral.com
- http://www.gladwell.com/2002/2002_08_05_a_face.htm
- http://faculty.fuqua.duke.edu/~tlc10/bio/pdf_articles/article_index.htm
- http://www.edge.org/3rd_culture/ramachandran/ramachandran_p1.html
10章 他者との関係
[Hack #94] 感情の表現
[Hack #95] 表情の感情に与える影響
[Hack #96] 感情の記憶への影響
[Hack #97] 視線
[Hack #98] 人は真似をする
あまり意識して考えたことがなかったけど、メタ認知について。
仕事(プログラミング・ウェブデザイン)をしていると必ず問題にぶちあたる。そしてパターンがる。
1. 小さな問題(~10分)
2. 前にも似たような経験をした問題(~1時間)
3. ハマる問題(1時間~)
1は比較的短時間で解決できてしまう、すぐに解決法が思い浮かぶ問題。
2は作業しているうちに、「ああこういうのは前にもぶちあたった」と思い出すので、
そのうち解けるだろうとなんとなくわかる問題。
3は、2かと思いきや見事に裏切られて原因の憶測すら困難な問題。
経験の積み重ねで、3だったものがどんどん1のほうへシフトしていき、1に堆積するイメージ。
不思議なのは、3を解決する瞬間というのは、だいたいが休憩を入れた直後だということ。
それはなんでか?と自問自答してみた。
だいたいの場合、1と2の延長で3をやっているので、完全に解決法がパターン化されてしまっている。すでに発想が出尽くしているのにもかかわらず、そこに執着し続けている。2のパターンに違いないと信じて、これでもか、これでもか、と頑張って本当に2ならいいのだが、それでもダメなときは「もうだめだー」と言って休憩する。実はこれが今までの方法には見切りをつけようという合図。休憩中は同じ回路に信号を流さないので、ちょっとRAMがクリアされる。そして再開したとき、「2の中に答えはないから3へ旅をはじめよう。」と要点をある程度客観視できる。そこにそれまでと大きな違いがある。重要なのは、それまでのフローをいかに忘れているかどうか。
絵を描いていたときのことを思い出す。描いた絵はひっくりかえしたり、顔を傾けてみてみたり、遠くからながめてみたり。
作曲をしていたときのことを思い出す。一度つくりあげたものを壊すと、全く新しい聴こえ方になるのが楽しくてしょうがなかったり。
何をするときも同じだと思った。3の前に妥協するという技術が一般的なのかもしれないが、それを解決したときの快感はこの上ないからやめられない。
そして、小さな単位で毎日それの繰り返しなのだが、生き方においてもっと休憩が必要だなと思う今日このごろ。
人間の、「忘れる」という能力はすばらしいと思う。
*追記
そういえば2や3で、人に相談すると自己解決するパターンもある。人に説明しているうちに勝手に要点がまとまって、まだ試していない選択肢が思い浮かぶからだ。
任意のアルバムアートワーク画像の探し方を探していたら、みつかったのでメモ。
http://forums.macosxhints.com/showthread.php?p=325382
こちらから引用:
These are Persistent IDs, which you can find in iTunes Music Library.xml and folder structure is like this:Library Persistent ID -> decimal value of last hex digit in tracks persistent ID -> dec value of before last hex digit -> dec value of 3rd hex digit from the end -> Library persistent ID - Track persistent ID .itc
まず、XMLの先頭にあるLibrary Persistent IDという部分がある:
<key>Library Persistent ID</key><string>B77A88149B472EF5</string>
そしてそれぞれのトラックは下記のように、ひとまとまりのエレメントになっている。
<key>142</key>
<dict>
<key>Track ID</key><integer>142</integer>
<key>Name</key><string>ハニー・ムーン</string>
<key>Artist</key><string>Tei Towa + Natural Calamity</string>
<key>Composer</key><string>細野晴臣</string>
<key>Album</key><string>細野晴臣トリビュート・アルバム Tribute to Haruomi Hosono [Disc 1]</string>
<key>Genre</key><string>Pop</string>
<key>Kind</key><string>AAC オーディオファイル</string>
<key>Size</key><integer>4811001</integer>
<key>Total Time</key><integer>294293</integer>
<key>Disc Number</key><integer>1</integer>
<key>Disc Count</key><integer>2</integer>
<key>Track Number</key><integer>9</integer>
<key>Track Count</key><integer>11</integer>
<key>Year</key><integer>2007</integer>
<key>Date Modified</key><date>2007-12-11T16:21:09Z</date>
<key>Date Added</key><date>2007-11-18T07:02:11Z</date>
<key>Bit Rate</key><integer>128</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Rating</key><integer>20</integer>
<key>Album Rating</key><integer>40</integer>
<key>Album Rating Computed</key><true/>
<key>Compilation</key><true/>
<key>Artwork Count</key><integer>1</integer>
<key>Persistent ID</key><string>34B5886AA718721C</string>
<key>Track Type</key><string>File</string>
<key>Location</key><string>file://localhost/L:/stage/nanmaci/%E3%83%8D%E3%82%BF/1-09%20%E3%83%8F%E3%83%8B%E3%83%BC%E3%83%BB%E3%83%A0%E3%83%BC%E3%83%B3.m4a</string>
<key>File Folder Count</key><integer>-1</integer>
<key>Library Folder Count</key><integer>-1</integer>
</dict>
その中の、<key>Persistent ID</key><string>34B5886AA718721C</string>という部分を使う。
これらを組み合わせて下記のように解析できる。
Library Persistent IDが
B77A88149B472EF5
Persistent IDが
34B5886AA718721C
の場合、
Persistent IDの
下1の桁の値「C」を10進数にして13
10の桁の値「1」を10進数にして01
100の桁の値「2」を10進数にして02
なので、
アートワークがiTunesで自動的にダウンロードされたものなら、
iTunes > Album Artwork > Download > B77A88149B472EF5 > 13 > 01 > 02 > B77A88149B472EF5-34B5886AA718721C.itc
アートワークが自分で追加したものなら、
iTunes > Album Artwork > Local > B77A88149B472EF5 > 13 > 01 > 02 > B77A88149B472EF5-34B5886AA718721C.itc
という感じ。とりあえず今回はiTunes7.5.0.20、Windows XP環境でのチェックのみだったのでMacでのフォルダ構造については不明。この複雑な仕組みは、別ソフトなどで画像を簡単に利用されないようにアップルが工夫したものな気がする。なのでiTunesのバージョンアップで変わる可能性がおおいにあり。
*ただし、アルバム単位で画像を決めている場合、トラックごとに画像が保存されているわけではなく、共有画像として動いているらしいが、その仕組みはよくわからない。
*以前はjpgで保存されていた気がするが、今はitcという拡張子になっている。itcファイルに関してはここやここを参考。
<div id="A">
<p><a>something link</a&></p>
</div>
となっているときに、<a>タグが効かないことがあった。
その場合、
#A {position:static;}
とすると動くようになった。もともとrelativeだった。理由はよくわからないけど、iepngfixが絡んでいる可能性あり。
![]()
Think ITのこちらの記事を読みながら、オンライン付箋を実際に作ってみたものの、RoRとAIRのバージョンがあがっていてうまく動作しなかったり、最後までできたけどスクリプト中途半端だっりしたたので、ある程度動くものに改造してみた。
とはいうものの、
ActionScript2は結構さわっていたけど、AS3は今回はじめて。
AIRもはじめて。
Ruby on Railsもはじめて。
コマンドプロンプトなんていうのもよくわからない。
と新年早々初めて三昧気味だったので、全体的にやっつけ感もあるけど、まぁ最初はこんなもんだ。
以下覚えている注意点
Ruby on Rails (Rails v2.0.2, ruby v1.6.8) :
●「scaffold_resource」は「scaffold」になった(参考)
●database.yamlでsyntax エラーが発生する(参考)
adapter: mysql
encoding: utf8
database: stickes_development
username: root
password: *********
host: localhost
というかんじで「:」のあとにスペースが必要。
それぞれの項目の前にタブをいれてもエラーになった。
●InvalidAuthenticityTokenというエラーが出る(参考)
protect_from_forgeryというので解決。
AIR (beta3):
●<rootContent>というタグはなくなったので<initialWindow>の中に<content>として入れる(参考)
●xmlns="http://ns.adobe.com/air/application/1.0.M6"
あとの仕様の変更はたくさんありすぎて、覚えていない。
そういうのを調べつつ、記事を読みながら完成させたが、ちょっとご本人もお忙しかったのか、あまり良い出来のものではなかった。
そこでカスタムし、
- アプリケーションを立ち上げると自動で付箋を読み込む
- 付箋を移動すると、自動保存
- テキストエリアに書き込むと、自動保存
- xボタンを押すと、削除
と、ある程度実用的なものにしてみた。
(RoR側の変更はなし。)
stickies-app.xml
<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/1.0.M6" minimumPatchLevel="1047">
<id>jp.onlinehusen</id>
<version>1.0</version >
<filename>オンライン付箋</filename>
<name>オンライン付箋</name>
<description>Ruby on RailsとAdobe AIRでデスクトップアプリを作るデモ</description>
<copyright>Copyright 2006</copyright>
<installFolder>Adobe/Examples</installFolder>
<programMenuFolder>Adobe/Examples</programMenuFolder>
<initialWindow>
<content>menu.swf</content>
<title>online husen</title>
<systemChrome>standard</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<width>60</width>
<height>20</height>
<x>250</x>
<y>0</y>
<minSize>10 10</minSize>
<maxSize>100 100</maxSize>
<minimizable>true</minimizable>
<maximizable>false</maximizable>
<resizable>false</resizable>
</initialWindow>
<icon>
</icon>
<customUpdateUI>false</customUpdateUI>
<allowBrowserInvocation>false</allowBrowserInvocation>
</application>
menu.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100" height="20" creationComplete="load();" closing="onClosing(event);" >
<mx:Script>
<![CDATA[
public var stickies:Array = new Array();
public var stickNum:Number = new Number();
public function create():void {
var sticky:Sticky = new Sticky();
stickNum++;
sticky.id = stickNum;
var request:URLRequest;
request = new URLRequest("http://localhost:3000/stickies.xml");
request.method = 'POST';
var variables : URLVariables = new URLVariables ();
variables['sticky[x]'] = sticky.window.x ;// Capabilities.screenResolutionX;
variables['sticky[y]'] = sticky.window.y ;// Capabilities.screenResolutionY;
variables['sticky[width]'] = sticky.window.width;
variables['sticky[height]'] = sticky.window.height;
variables['sticky[body]'] = sticky.editor.text;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.load(request);
sticky.show();
stickies.push(sticky);
}
public function load():void {
var request:URLRequest = new URLRequest("http://localhost:3000/stickies.xml");
request.method = 'GET';
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(e:Event):void {
var xml:XML = new XML(e.target.data);
var sL:Number = xml.sticky.length();
for each(var element:Object in xml.sticky){
var sticky:Sticky = new Sticky();
sticky.createNew = new Boolean(false);
sticky.id = element.id;
sticky.editor.text = element.body;
sticky.window.x = element.x; //* Capabilities.screenResolutionX;
sticky.window.y = element.y; //* Capabilities.screenResolutionY;
sticky.window.width = element.width;
sticky.window.height = element.height;
sticky.show();
stickNum = sticky.id;
stickies.push(sticky);
}
});
loader.load(request);
}
private function onClosing(event:Event):void {
for each (var sticky:Sticky in stickies) {
if(sticky){
sticky.window.close();
}}
}
]]>
</mx:Script>
<mx:Button left="10" top="10" label="new" id="new_btn" click="create();" />
<!--<mx:Button right="60" top="10" label="load" id="load_btn" click="load();" /> -->
<!-- <mx:Button right="10" top="10" label="save" id="save_btn" /> click="save();" -->
<!--<mx:TextArea right="10" top="40" left="10" bottom="10" id="messages" />-->
</mx:WindowedApplication>
menu.mxml
package {
import flash.text.*;
import flash.display.*;
import flash.events.*;
import flash.system.*;
import mx.controls.*;
import flash.net.*;
import flash.utils.Timer;
public class Sticky extends Sprite{
public var window:NativeWindow;
public var editor:TextField;
public var id:Number;
public var createNew:Boolean;
public var button:SimpleButton = new SimpleButton( );
public var timer:Timer = new Timer(1000,1);
public static var RESIZE_HANDLE_SIZE:int = 20;
public function Sticky():void {
timer.addEventListener(TimerEvent.TIMER,onTick);
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
initOptions.systemChrome = NativeWindowSystemChrome.NONE;
initOptions.transparent = false;
initOptions.type = NativeWindowType.LIGHTWEIGHT;
window = new NativeWindow(initOptions);
window.stage.align = StageAlign.TOP_LEFT;
window.stage.scaleMode = StageScaleMode.NO_SCALE;
editor = new TextField();
editor.x = editor.y = 0;
editor.selectable = true;
editor.border = false;
editor.type = TextFieldType.INPUT;
editor.multiline = true;
editor.background = true;
editor.wordWrap = true;
editor.backgroundColor = 0xE6E082;
window.stage.addChild(editor);
window.width = editor.width = 300;
window.height = editor.height = 100;
window.stage.addEventListener(Event.RESIZE, function(evt:Event):void {
resized();
});
window.stage.addEventListener(MouseEvent.MOUSE_DOWN,
function(evt:MouseEvent):void {
var x:Number = evt.stageX;
var y:Number = evt.stageY;
if (y > window.height - RESIZE_HANDLE_SIZE && x > window.width - RESIZE_HANDLE_SIZE) {
window.startResize(NativeWindowResize.BOTTOM_RIGHT);
}
else {
window.startMove();
}
}
);
window.stage.addEventListener(MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
save();
}
);
editor.addEventListener(TextEvent.TEXT_INPUT,
function(evt:TextEvent):void {
if(timer){
timer.stop();
}
timerSave();
}
);
} // end of function Sticky
public function show():void {
window.visible = true;
//閉じるボタンの生成
button.x = window.width-15;
button.y = 5;
button.upState = createBox( 0xE6E082, 10 ,0.3);
button.overState = createBox( 0xE6E082, 10 ,1);
button.downState = createBox( 0xCCCCCC, 10 ,1);
button.hitTestState = button.upState;
button.addEventListener( MouseEvent.CLICK, onMouseDown );
window.stage.addChild( button );
}
public function resized():void {
editor.width = window.width;
editor.height = window.height;
button.x = window.width-15;
button.y = 5;
save();
}
public function save():void {
var request:URLRequest;
request = new URLRequest("http://localhost:3000/stickies/"+id+".xml");
request.method = 'PUT';
var variables : URLVariables = new URLVariables ();
variables['sticky[x]'] = window.x ;// Capabilities.screenResolutionX;
variables['sticky[y]'] = window.y ;// Capabilities.screenResolutionY;
variables['sticky[width]'] = window.width;
variables['sticky[height]'] = window.height;
variables['sticky[body]'] = editor.text;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.load(request);
}
private function onMouseDown(e:MouseEvent):void{
trace("onMouseDown");
var requ:URLRequest = new URLRequest("http://localhost:3000/stickies/"+id+".xml");
requ.method = 'DELETE';
var loader:URLLoader = new URLLoader();
loader.load(requ);
window.close();
}
private function createBox( color:uint, radius:Number ,vis:Number):Shape {
var xShape:Shape = new Shape( );
xShape.graphics.lineStyle( 1, 0x000000 );
xShape.graphics.beginFill( color );
xShape.graphics.drawRect( 0, 0, radius ,radius);
xShape.graphics.moveTo( 0, radius );
xShape.graphics.lineTo( radius, 0);
xShape.graphics.moveTo( radius, radius );
xShape.graphics.lineTo( 0, 0);
xShape.graphics.endFill( );
xShape.alpha = vis;
return xShape;
}
public function timerSave():void{
timer.start();
}
public function onTick (evt:TimerEvent):void {
timer.stop();
save();
}
} // end of class Sticky
} // end of package
ロリポップのサーバがこわれてデータが全部消えたので、mt4にしてみた。
rightfieldsがまだmt4に対応していないので、それまでpokeal playerは復活できません。
最近はflashにとどまらず、Ruby on RailsやAirのお勉強もしているので、そのへんのよしなしごとをメモしていきます。
