Flex勉強会@福岡に参加してきたよ
昨日はFlexUG福岡の第1回勉強会に参加してきました。
(写真は代表のid:re_shikajiro)
んで、私もライトニングトークに参加
無料で作るFlex/AIR
今週から勉強を始めたFlex。View more documents from hiroshinakao.
大したことは話せないので、勉強ついでに作ったプレゼンツールを使用。
反応は悪くなかったかなー。
んで、ソース公開
制作はFlashDevelopで行いました。
CSSとかACを直接書いたんだけど、実際は別ファイルにした方が見やすい。
この辺はHTML書く感覚と変わらないのがいいね。
ポイント
- 「File.desktopDirectory.resolvePath("presentaion.txt");」でデスクトップにある"presentaion.txt"というファイルを取得。
- 読み込んだファイルを"++改行"でページ分け、"--改行"で見出しと本文を分割しています。
Main.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="init();"> <mx:Style> <![CDATA[ WindowedApplication{ backgroundGradientColors:#000, #555; } .caption, .message{ horizontalAlign:center; color:#fff; fontFamily:"MS ゴシック, Osaka-等幅"; } .caption{ fontSize:56px; fontWeight:bold; } .message{ fontSize:40px; } .header, .main{ verticalAlign: middle; horizontalAlign:center; } .footer{ verticalAlign: bottom; horizontalAlign:right; } VBox{ margin:0px; padding:0px; horizontalAlign:center; } ]]> </mx:Style> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.controls.Label; import flash.filesystem.*; import flash.desktop.NativeApplication; public var lines:Array; public var pageNo:int = 0; private function init():void { var file:File = File.desktopDirectory.resolvePath("presentaion.txt"); var stream:FileStream = new FileStream(); try { stream.open(file, FileMode.READ); lines = stream.readMultiByte(stream.bytesAvailable, File.systemCharset) .split("++" + File.lineEnding); }catch (err:IOError) { NativeApplication.nativeApplication.exit(); }finally { if(stream != null) stream.close(); } setMessage(); } private function nextPage():void { ++pageNo; if (pageNo == lines.length) { NativeApplication.nativeApplication.exit(); } setMessage(); } private function returnPage():void { if (pageNo > 0) { --pageNo; }else { Alert.show("最初のページです"); } setMessage(); } private function setMessage():void { header.visible = false; main.visible = false; header.removeAllChildren(); main.removeAllChildren(); var topics:Array = lines[pageNo].split("--" + File.lineEnding); if (topics.length == 1) { addChildren(main, topics[0], "message"); }else { addChildren(header, topics[0], "caption"); addChildren(main, topics[1], "message"); } header.visible = true; main.visible = true; } private function addChildren(parent:VBox, line:String, style:String):void { var columns:Array = line.split(File.lineEnding); for (var i:String in columns){ var tempLabel:Label = new Label(); tempLabel.styleName = style; tempLabel.text = columns[i]; parent.addChild(tempLabel); } } ]]> </mx:Script> <mx:Sequence id="buttonEffect"> <mx:Parallel> <mx:WipeLeft target="{header}" id="headerRightEffect" duration="1000" /> <mx:WipeRight target="{main}" id="mainRightEffect" duration="1000" /> </mx:Parallel> </mx:Sequence> <mx:Zoom id="shrink" duration="100" zoomHeightTo=".9" zoomWidthTo=".9" /> <mx:Zoom id="revert" duration="50" zoomHeightTo="1" zoomWidthTo="1" /> <mx:VBox id="header" styleName="header" width="100%" height="100%" /> <mx:VBox id="main" styleName="main" width="100%" height="100%" /> <mx:HBox styleName="footer" width="100%" height="100%"> <mx:Button styleName="next" label="Back" click="returnPage();" mouseDownEffect="{buttonEffect}" /> <mx:Button styleName="next" label="Next" click="nextPage();" mouseDownEffect="{buttonEffect}" /> </mx:HBox> </mx:WindowedApplication>