今日気になったページ
ペンで書いたような、味のある10個の手書きのフォント
フリーで使えるいい感じの手書き風フォント特集(日本語も)
メールとかチャットで使ったら面白そう。
Creating generative art with Flash
Flashでデザイン。まだ読んでないけど気になったのでペタペタ
Maps in Flash and Flex Presentation
いろんなマップの資料。元ネタFlex Coderさん
A Map of Olympic Medals
オリンピックのメダル取得グラフ
GraphicsUtil. A Utility Class for Drawing Arrows
矢印なクラス。便利。
Flex Builder Linux Alpha 4 Released on Labs
LinuxでもFlex!
SWiSH miniMax2 - Make Flash Quick and Easy
Flash作成ソフトSWiSHにmini版が登場。値段も$69.97と通常版に比べて安くなってます。体験ダウンロードはこちら
YoutubeなAIRアプリを作ってみました。
サンプルとしてYoutubeなAIRアプリを作ってみました。
こんな感じ
アプリのダウンロード
「Ctrl + w」もしくは右上のCloseボタンでアプリを終了することができます。
それにしてもYoutubeのページダウンロードがすこぶる重い。
今回の勉強は正規表現でflvなURLを引っこ抜いて作成です。
//youtube のページからflvのURLを作成 private function accessSuccess(evt:Event):void{ myProgress.visible = false; var startIndex:int =0; var endIndex:int =0; var pattern:RegExp = /=&t=/; var myArr:Array = pattern.exec(watchLoader.data); startIndex = myArr["index"]; pattern = /&hl=/; myArr = pattern.exec(watchLoader.data); endIndex = myArr["index"]; var tmpArr:Array = nowurl.split("?v="); var flvurl:String = "http://youtube.com/get_video.php?video_id=" + tmpArr[1] + "&t=" + watchLoader.data.substring( startIndex +4 , endIndex ); myVideo.source = flvurl; }
正規表現を二回使っているけど、うまくやればたぶん、一回でいけると思う。
全体のプログラムソースはこちら
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalScrollPolicy="off" showGripper="false" showInAutomationHierarchy="false" showStatusBar="false" showTitleBar="false" borderThickness="0" closing="closeHandler()" keyDown="onKey(event)" creationComplete="init()" width="100%" height="100%" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#6F6F6F, #000000]" xmlns:jirox="net.jirox.*"> <mx:Script> <![CDATA[ //初期化関数 private var so:SharedObject; private function init():void{ this.setFocus(); this.nativeWindow.x = 0; this.nativeWindow.y = 0; this.nativeWindow.width = Capabilities.screenResolutionX; this.nativeWindow.height = Capabilities.screenResolutionY; //シェアードオブジェクトゲット so = SharedObject.getLocal("kyoutubeAir"); if( so.data.word ){ inputTxt.text = so.data.word; }else{ } } //現在のウィンドウ情報を保存しとく private function closeHandler():void{ //so.flush(); } //youtube検索 private function onSearch():void{ if( inputTxt.text != "" ){ so.data.word = inputTxt.text; hts.send({"word":inputTxt.text}); } } //検索完了イベント private function onResult():void{ } //動画リストからクリックされたとき private function onClick():void{ playMovie(); } //youtube の URL から flvURLをゲット private var watchLoader:URLLoader = new URLLoader(); private var nowurl:String; public function playMovie():void{ myProgress.visible = true; var url:String = tl.selectedItem.url; nowurl = url; var watchURL:URLRequest = new URLRequest(url + "&fmt=6" ); watchURL.method = "GET"; watchLoader = new URLLoader(); watchLoader.addEventListener( Event.COMPLETE , accessSuccess ); watchLoader.addEventListener(ProgressEvent.PROGRESS , function():void{ myProgress.label = watchLoader.bytesLoaded + "/" + watchLoader.bytesTotal;; }); watchLoader.load( watchURL ); } //youtube のページからflvのURLを作成 private function accessSuccess(evt:Event):void{ myProgress.visible = false; var startIndex:int =0; var endIndex:int =0; var pattern:RegExp = /=&t=/; var myArr:Array = pattern.exec(watchLoader.data); startIndex = myArr["index"]; pattern = /&hl=/; myArr = pattern.exec(watchLoader.data); endIndex = myArr["index"]; var tmpArr:Array = nowurl.split("?v="); var flvurl:String = "http://youtube.com/get_video.php?video_id=" + tmpArr[1] + "&t=" + watchLoader.data.substring( startIndex +4 , endIndex ); myVideo.source = flvurl; } //動画再生終わったので次の動画 private function nextMovie():void{ if( tl.selectedIndex >= hts.lastResult.item.length -1 ){ tl.selectedIndex = tl.selectedIndex + 1; }else{ tl.selectedIndex = 0; } playMovie(); } //アプリをキーボードから閉じる private function onKey(e:KeyboardEvent):void{ if( e.charCode == 119 && e.ctrlKey ){ this.nativeWindow.close(); } } [Bindable]private var canvasVisible:Boolean = true; private function setCanvas():void{ if( canvasVisible ){ canvasVisible = false; hideCanvas.play([myCanvas]); }else{ showCanvas.play([myCanvas]); canvasVisible = true; } } import mx.effects.easing.*; ]]> </mx:Script> <mx:Style> TileList{ alternatingItemColors: #999999, #cccccc; rollOverColor: #666666; textRollOverColor: #ffffff; selectionColor: #333333; color: #333333; textSelectedColor: #ffffff; } Button { cornerRadius: 0; textIndent: 0; highlightAlphas: 0.68, 0.45; fillAlphas: 1, 0.94, 0.75, 0.65; fillColors: #333333, #ffffff, #000000, #666666; color: #000000; themeColor: #009dff; } </mx:Style> <!--########## ##########--> <jirox:AirAutoUpdater url="http://moeten.info/air/kyoutubeAir/version.xml"/> <!--########## ##########--> <mx:HTTPService id="hts" url="http://moeten.info/maidcafe/?m=moesearch_new&type=youtube&ptype=xml" resultFormat="e4x" result="onResult()" showBusyCursor="true"/> <mx:Move id="hideCanvas" xFrom="0" xTo="{-myCanvas.width+30}"/> <mx:Move id="showCanvas" xTo="0" xFrom="{-myCanvas.width+30}"/> <!--########## ##########--> <mx:VideoDisplay id="myVideo" x="0" y="0" width="100%" height="100%" complete="nextMovie()"/> <mx:ProgressBar x="0" y="0" width="100%" indeterminate="true" themeColor="#092435" label="now Loading..." id="myProgress" trackHeight="10" showEffect="WipeRight" hideEffect="WipeRight" visible="false" color="0xcccccc" labelPlacement="right" textAlign="right"/> <mx:Canvas visible="{tl.selectedItem}" x="480" y="858" width="468" height="132" cornerRadius="10" borderThickness="3" borderColor="0x999999" borderStyle="solid" backgroundAlpha="0.4" backgroundColor="0x333333" bottom="10" right="10" alpha="0.8" showEffect="Fade"> <mx:Image x="10" y="10" width="130" height="106" source="{tl.selectedItem.img}"/> <mx:TextArea x="148" y="36" width="310" height="80" backgroundAlpha="0" editable="false" selectable="false" htmlText="{tl.selectedItem.comment}" textAlign="left" color="0x999999" borderThickness="0" borderStyle="solid"/> <mx:Label x="148" y="10" text="{tl.selectedItem.title}" width="310" color="0x999999" textAlign="left"/> </mx:Canvas> <mx:Canvas id="myCanvas" x="0" y="0" width="250" height="100%"> <mx:Button x="162" y="18" label="検索" click="onSearch()"/> <mx:TextInput id="inputTxt" text="" x="10" y="18" width="144" enter="onSearch()" backgroundColor="#cccccc" color="#000000" borderThickness="1" borderColor="0x000000" borderStyle="solid"/> <mx:TileList id="tl" x="10" y="48" width="200" height="100%" alpha="0.6" backgroundAlpha="0.5" rowHeight="50" columnWidth="200" itemClick="onClick()" dataProvider="{hts.lastResult.item}" itemRenderer="thumRender"/> <mx:LinkButton x="212" y="15" label=">" width="34" height="25" click="setCanvas()" fontSize="12" color="0x999999"/> </mx:Canvas> <mx:LinkButton x="876" y="10" label="Close" click="{this.nativeWindow.close()}" color="0x999999" right="0"/> </mx:WindowedApplication>
ちょっと便利な付箋アプリを作りました。
ちょっと便利な付箋アプリを作ってみました。
こんな感じ
色とかサイズとかURLがつけられるのが便利かなぁ。
アプリのダウンロード
データーはSharedObjectに保存しています。
#ホントはSqliteで遊ぶと面白いんだろうけど、今回は簡単にってことで(^^;
ドラッグやリサイズできるパネルってことでSuperPanelPlusを使用しています。
メインのソースコードはこちら
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:panel="com.visualempathy.extensions.panel.*" xmlns:local="*" layout="absolute" backgroundAlpha="0" borderThickness="0" showGripper="false" showInAutomationHierarchy="false" showStatusBar="false" showTitleBar="false" verticalScrollPolicy="off" horizontalScrollPolicy="off" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.managers.PopUpManager; //初期化関数 public var so:SharedObject; private function init():void{ // this.setFocus(); this.nativeWindow.x = 0; this.nativeWindow.y = 0; this.nativeWindow.width = Capabilities.screenResolutionX; this.nativeWindow.height = Capabilities.screenResolutionY; doPopup(); } public function doPopup():void{ //シェアードオブジェクトゲット so = SharedObject.getLocal("khusenAir"); var popup_window:myPanel = new myPanel(); popup_window.myText = so.data.myText; popup_window.x = so.data.x; popup_window.y = so.data.y; if( so.data.width ){ popup_window.width = so.data.width; popup_window.height = so.data.height; }else{ popup_window.width = 200; popup_window.height = 400; } this.addChild( popup_window ); // PopUpManager.addPopUp(popup_window, this); // PopUpManager.centerPopUp(popup_window); } ]]> </mx:Script> </mx:WindowedApplication>
SuperPanelPlusを拡張したmyPanelのソースコードはこちら
リッチテキストエディターが追加されています。
<?xml version="1.0" encoding="utf-8"?> <SuperPanelPlus xmlns="com.visualempathy.extensions.panel.*" xmlns:mx="http://www.adobe.com/2006/mxml" title="付箋" width="300" height="600" layout="vertical" horizontalAlign="right" showControls="true" dragEnabled="true" resizeEnabled="true" styleColor="0x333333" backgroundColor="#333333" borderColor="#333333" color="0xffffff" backgroundAlpha="0.9" selectedBorderAlpha="0.8" unselectedBorderAlpha="0.5" moveAlpha=".5" highlightAlpha1=".3" highlightAlpha2=".1" verticalScrollPolicy="off" horizontalScrollPolicy="off" creationCompleteEffect="Fade" closeClickEvent="onClose()"> <mx:Script> <![CDATA[ /* private function closeWindow( event:Event ):void { this.alpha = 0; this.visible = false; this.includeInLayout = false; } private function showWindow( event:Event ):void { this.alpha = 1; this.visible = true; this.includeInLayout = true; } */ [Bindable]public var myText:String; //エディターの表示・非表示 private var showed:Boolean = false; private function setEdite():void{ if( showed ){ rte.showControlBar = false; showed = false; lb.label = "Show Editor"; }else{ showed = true; rte.showControlBar = true; lb.label = "Close Editor"; } } import mx.core.Application; //テキストを保存 private function saveText():void{ Application.application.so.data.myText = rte.htmlText; Application.application.so.flush(); } //位置情報やサイズ情報を保存 private function onClose():void{ Application.application.so.data.x = this.x; Application.application.so.data.y = this.y; Application.application.so.data.width = this.width; Application.application.so.data.height = this.height; Application.application.so.flush(); Application.application.nativeWindow.close(); } ]]> </mx:Script> <mx:Style> .myText{ backgroundAlpha:0.1; color:#ffffff; } .myControl{ backgroundAlpha:1; color:#000000; } ComboBox{ backgroundAlpha:1; } </mx:Style> <mx:Style source="assets/css/styles.css"/> <!-- <mx:Resize id="showEdite" heightFrom="{this.height+100}" heightTo="{this.height}"/> <mx:Resize id="hideEdite" heightFrom="{this.height}" heightTo="{this.height+100}"/> --> <mx:RichTextEditor id="rte" width="100%" height="100%" showInAutomationHierarchy="false" showControlBar="false" htmlText="{myText}" borderThickness="0" change="saveText()" headerHeight="4" backgroundAlpha="0.5" alpha="1.0" borderAlpha="0.5" disabledOverlayAlpha="0.5" highlightAlphas="0.5" backgroundColor="#000000" borderColor="#000000" textAreaStyleName="myText" controlBarStyleName="myControl"/> <mx:LinkButton id="lb" label="Show Editor" bottom="3" right="3" click="setEdite()" color="0xffffff"/> </SuperPanelPlus>