Mais conteúdo relacionado
Semelhante a 20090418 イケテルRails勉強会 第2部Air編 (20)
20090418 イケテルRails勉強会 第2部Air編
- 6. Adobe Systems が開発する、デスクトップ・リッチ
インターネットアプリケーション (RIA) を開発・
実行するための複数のオペレーティングシステム
に対応したランタイムライブラリである。
※リッチインターネットアプリケーション
⇒ウェブブラウザなどのクライアントの機能を活かした、柔軟な
インターフェースをもつウェブアプリケーションのこと。
(Wikipediaより)
6
- 14. コンパイルしましょう。
amxmlc src/IketeruGourmet.mxml -output src/IketeruGourmet.swf
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
設定ファイル quot;D:¥develop¥Adobe¥flex_sdk_3¥frameworks¥air-
config.xmlquot; をロードしています
C:¥IketeruGourmet¥src¥IketeruGourmet.swf (486726 bytes)
このメッセージが表示されたら、
コンパイルOK。
14
- 19. その1
src/rbc/view/GoogleMaps.mxml
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<PodContentBase 赤色の部分を追加
してください。
xmlns=quot;rbc.view.*quot;
xmlns:maps=quot;com.google.maps.*quot;
xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
width=quot;100%quot; height=quot;100%quot;>
<maps:Map
id=quot;mapquot;
width=quot;100%quot;
height=quot;100%quot;
url=quot;http://localhost/quot;
key=quot;ABQIAAAA3hk8tSWJBtrv7SdGaRNVahT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSwJelIuU1E96KfDhGIXqqayaU9HAquot;
mapevent_mapready=quot;displayMap(event)quot;
/>
</PodContentBase>
19
- 20. その2
src/rbc/view/GoogleMaps.mxml
<mx:Script> 前ページの<PodContentBase>タグと<maps>
<![CDATA[ タグの間に全て追加してください。
import com.google.maps.*;
import com.google.maps.controls.*;
private function displayMap(event:MapEvent):void {
map.setCenter(
new LatLng(35.690137,139.692836),
16,
MapType.NORMAL_MAP_TYPE);
map.addControl(new ZoomControl());
map.addControl(new PositionControl());
map.addControl(new MapTypeControl());
}
]]>
</mx:Script>
20
- 21. コンパイルしましょう。
amxmlc src/IketeruGourmet.mxml -output src/IketeruGourmet.swf -
library-path+=libs/map_flex_1_9.swc
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
設定ファイル quot;D:¥develop¥Adobe¥flex_sdk_3¥frameworks¥air-
config.xmlquot; をロードしています
C:¥IketeruGourmet¥src¥IketeruGourmet.swf (486726 bytes)
このメッセージが表示されたら、
コンパイルOK。
21
- 25. src/rbc/view/SearchResult.mxml
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<PodContentBase
赤色の部分を追加
xmlns=quot;rbc.view.*quot;
してください。
xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
width=quot;100%quot; height=quot;100%quot;>
<mx:DataGrid id=quot;dataGridquot; width=quot;100%quot; height=quot;100%quot;>
<mx:columns>
<mx:DataGridColumn headerText=quot;名称quot; dataField=quot;restaurant_namequot; visible=quot;truequot; width=quot;180quot;/>
<mx:DataGridColumn headerText=quot;URLquot; dataField=quot;tabelog_urlquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;総合評価quot; dataField=quot;total_scorequot; visible=quot;truequot; width=quot;45quot;/>
<mx:DataGridColumn headerText=quot;料理・味quot; dataField=quot;taste_scorequot; visible=quot;truequot; width=quot;45quot;/>
<mx:DataGridColumn headerText=quot;サービスquot; dataField=quot;service_scorequot; visible=quot;truequot; width=quot;45quot;/>
<mx:DataGridColumn headerText=quot;雰囲気quot; dataField=quot;mood_scorequot; visible=quot;truequot; width=quot;45quot;/>
<mx:DataGridColumn headerText=quot;シチュエーションquot; dataField=quot;situationquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;価格(夜)quot; dataField=quot;dinner_pricequot; visible=quot;truequot; width=quot;90quot;/>
<mx:DataGridColumn headerText=quot;価格(昼)quot; dataField=quot;lunch_pricequot; visible=quot;truequot; width=quot;90quot;/>
<mx:DataGridColumn headerText=quot;カテゴリquot; dataField=quot;categoryquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;最寄り駅quot; dataField=quot;stationquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;住所quot; dataField=quot;addressquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;電話番号quot; dataField=quot;telquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;営業時間quot; dataField=quot;business_hoursquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;休日quot; dataField=quot;holidayquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;緯度quot; dataField=quot;latitudequot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;経度quot; dataField=quot;longitudequot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;メモquot; dataField=quot;memoquot; visible=quot;falsequot;/>
<mx:DataGridColumn headerText=quot;画像quot; dataField=quot;image_urlquot; visible=quot;falsequot;/>
</mx:columns>
</mx:DataGrid>
</PodContentBase>
25
- 26. コンパイルしましょう。
amxmlc src/IketeruGourmet.mxml -output src/IketeruGourmet.swf -
library-path+=libs/map_flex_1_9.swc
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
設定ファイル quot;D:¥develop¥Adobe¥flex_sdk_3¥frameworks¥air-
config.xmlquot; をロードしています
C:¥IketeruGourmet¥src¥IketeruGourmet.swf (486726 bytes)
このメッセージが表示されたら、
コンパイルOK。
26
- 30. その1
src/rbc/view/SearchCondition.mxml
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert; 赤色の部分を追加
してください。
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.utils.ObjectProxy;
import data.SearchConditionData;
import rbc.managers.SharedVariable;
30
- 31. その2
src/rbc/view/SearchCondition.mxml
private function onClickBtnSearch(e:MouseEvent):void {
var httpService:HTTPService = new HTTPService();
httpService.url = quot;http://localhost:3000/restaurants.xmlquot;;
httpService.resultFormat = HTTPService.RESULT_FORMAT_E4X;
httpService.addEventListener(ResultEvent.RESULT, resultHandler);
httpService.addEventListener(FaultEvent.FAULT, faultHandler);
var parameters:Object = new Object();
parameters.Prefecture = cboPrefecture.selectedItem.data;
parameters.SortOrder = cboSortOrder.selectedItem.data;
parameters.PageNum = cboPage.selectedItem.data;
parameters.ResultSet = quot;largequot;;
httpService.send(parameters);
} 赤色の部分を追加
してください。
31
- 32. その3
src/rbc/view/SearchCondition.mxml
前ページのonClickBtnSearchの後に
全て追加してください。
private function resultHandler(e:ResultEvent):void {
var itemList:XMLList = e.result.items.item;
sharedVariable.searchResult = this.xmlListToArrayCollection(itemList);
}
private function faultHandler(e:FaultEvent):void {
Alert.show(quot;通信エラーが発生しました!¥nquot; + e.toString());
}
32
- 33. その1
src/rbc/view/GoogleMaps.mxml
<mx:Script>
<![CDATA[ 赤色の部分を追加
import com.google.maps.*; してください。
import com.google.maps.controls.*;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import mx.collections.ArrayCollection;
import mx.events.PropertyChangeEvent;
import mx.utils.ObjectProxy;
33
- 34. その2
src/rbc/view/GoogleMaps.mxml
override protected function onChangeSharedVariable(e:PropertyChangeEvent):void {
map.clearOverlays();
var result:ArrayCollection = sharedVariable.searchResult;
for(var i:Number=0; i<result.length; i++) {
if(i==0) {
map.setCenter(
new LatLng(result[i].latitude, result[i].longitude),
16,
MapType.NORMAL_MAP_TYPE);
}
displayMapの後に全て
this.addMarker(result[i], i);
追加してください。
}
}
private function addMarker(result:ObjectProxy, index:Number):void {
var marker:Marker
= new Marker(
new LatLng(result.latitude, result.longitude),
new MarkerOptions({draggable:true, hasShadow:true}));
map.addOverlay(marker);
}
34
- 35. src/rbc/view/SearchResult.mxml
<mx:DataGrid>タグの前に
全て追加してください。
<mx:Script>
<![CDATA[
import mx.events.PropertyChangeEvent;
override protected function onChangeSharedVariable(e:PropertyChangeEvent):void {
dataGrid.dataProvider = sharedVariable.searchResult;
}
]]>
</mx:Script>
35
- 36. コンパイルしましょう。
amxmlc src/IketeruGourmet.mxml -output src/IketeruGourmet.swf -
library-path+=libs/map_flex_1_9.swc
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
設定ファイル quot;D:¥develop¥Adobe¥flex_sdk_3¥frameworks¥air-
config.xmlquot; をロードしています
C:¥IketeruGourmet¥src¥IketeruGourmet.swf (486726 bytes)
このメッセージが表示されたら、
コンパイルOK。
36
- 40. src/rbc/view/GoogleMaps.mxml
private function addMarker(result:ObjectProxy, index:Number):void {
var marker:Marker = new Marker(
赤色の部分を追加
new LatLng(result.Latitude, result.Longitude),
してください。
new MarkerOptions({draggable:true, hasShadow:true}));
marker.addEventListener(MapMouseEvent.CLICK,
function(event:MapMouseEvent):void {
var infoWindowOptions:InfoWindowOptions = new InfoWindowOptions();
infoWindowOptions.contentHTML
= quot;店名:quot;+ result.restaurant_name + quot;<br/>quot; +
quot;住所:quot;+ result.address + quot;<br/>quot; +
quot;TEL:quot;+ result.tel + quot;<br/>quot; +
quot;URL:quot;+ quot;<a href='quot; + result.tabelog_url + quot;'><b>ココをクリック!</b></a>quot; + quot;<br/>quot;;
if(result.memo != null && result.memo != quot;quot;) {
infoWindowOptions.contentHTML
= infoWindowOptions.contentHTML + quot;メモ:quot; + result.memo + quot;<br/>quot;;
}
if(result.image_url != null && result.image_url != quot;quot;) {
infoWindowOptions.contentHTML
= infoWindowOptions.contentHTML + quot;画像:quot; + quot;<a href='quot; + result.image_url + quot;'><b>ココをクリック!</b></a>quot;;
}
infoWindowOptions.width = 350;
marker.openInfoWindow(infoWindowOptions);
map.setCenter(new LatLng(result.latitude, result.longitude), 16, MapType.NORMAL_MAP_TYPE);
}
);
map.addOverlay(marker);
}
40
- 41. コンパイルしましょう。
amxmlc src/IketeruGourmet.mxml -output src/IketeruGourmet.swf -
library-path+=libs/map_flex_1_9.swc
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
設定ファイル quot;D:¥develop¥Adobe¥flex_sdk_3¥frameworks¥air-
config.xmlquot; をロードしています
C:¥IketeruGourmet¥src¥IketeruGourmet.swf (486726 bytes)
このメッセージが表示されたら、
コンパイルOK。
41
- 42. adl application.xml
コマンドプロンプトで
↑のコマンドを実行
して画面を表示
マーカーをクリックすると・・・
該当マーカーが地図の中央に移動して、
吹き出しが表示されます。
42
- 45. AIRパッケージを作成しましょう。
adt -package -storetype pkcs12 -keystore IketeruGourmet.p12 -
storepass iketeru IketeruGourmet.air application.xml icons libs src
コマンドプロンプトを起動後、
C:¥IketeruGourmetに移動して
コマンドを実行してください。
C:¥IketeruGourmet>
次のプロンプトが表示
されたら、OK。
45
- 47. ②インストーラが起動するので、
「インストール」をクリック
① IketeruGourmet.air
をダブルクリック
③「続行」をクリック
④インストールが
完了すると・・・
47