2011年9月30日金曜日

ex7 HTMLからSWFへの引数渡し


20110930.swf

1.FLAファイルにwindowレイヤー追加
ActionScript(windowレイヤー)
user = _root.user;
money = _root.money;

2.windowレイヤーにダイナミックテキストを2つ設置
(それぞれ変数名を「user」「money」とする)

3.SWFファイルをパブリッシュ

4.SWFと同時に生成されたHTMLファイルを編集(修正箇所:2)
修正1
<param name="movie" value="20110930.swf" />
→
<param name="movie" value="20110930.swf?user=sato&money=100" />

修正2
<embed src="20110930.swf" quality="high" bgcolor="#ffffff" width="320" height="240" name="20110930" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
→
<embed src="20110930.swf?user=sato&money=100" quality="high" bgcolor="#ffffff" width="320" height="240" name="20110930" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

5.SWFとHTMLをアップロードし,動作確認

ダウンロード1
ダウンロード2

2011年9月29日木曜日

外部APIを利用したWEBサービスのサンプル(5)

Google Mapsのオーバーレイ機能を利用して,以下の要件を満たすHTMLファイルを作成せよ.

参考サイト
Google Maps JavaScript API V3 オーバーレイ

要件
1. 地図上の学校の場所に,アイコンを表示 → マーカー
2. アイコンをクリックした際に吹き出しを表示し,吹き出し内に学校名と電話番号を表示 → 情報ウィンドウ
3. 駅から学校までの通学路を線として表示 → ポリライン
表示例

LINK

overlays.html
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Marker Simple</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  function initialize() {
    var myLatlng = new google.maps.LatLng(35.4649755,139.6162225);
    var mySchool = new google.maps.LatLng(35.463763,139.60973);
    var myStation = new google.maps.LatLng(35.466188, 139.622715);

    var myOptions = {
      zoom: 15,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
      position: mySchool,
      map: map,
      title:"school"
    });

  var route = [
    new google.maps.LatLng(35.466188, 139.622715),
    new google.maps.LatLng(35.463458,139.615631),
    new google.maps.LatLng(35.465424,139.612021),
    new google.maps.LatLng(35.463283,139.610087),
    new google.maps.LatLng(35.463763,139.60973)
  ];

  var routePath = new google.maps.Polyline({
    path: route,
    strokeColor: "#FF0000",
    strokeOpacity: 1.0,
    strokeWeight: 2
  });

  routePath.setMap(map);

  }
</script>
</head>
<body onload="initialize()">
  <div id="map_canvas"></div>
</body>
</html>

外部APIを利用したWEBサービスのサンプル(4)

外部APIを利用して,地名や固有名詞等の単語(名称)から座標を調べる.

参考サイト
Google Geocoding API

API書式
http://maps.google.com/maps/api/geocode/xml?address="(名称)"&sensor=true

LINK

外部APIを利用したWEBサービスのサンプル(3)

外部APIを利用して,地図上にデータのマッピングを行う.

参考サイト
Google Map JavaScript API(V3)

手順
1. script タグを使用して Maps API JavaScript を読み込み
2. 「map_canvas」という名前の div 要素を作成して、地図を保管
3. 多数の地図のプロパティを持つ JavaScript オブジェクトリテラルを作成
4. 「map」オブジェクトを作成する JavaScript 関数を記述
5. map オブジェクトを body タブの onload·イベントから初期化
表示例

LINK

map.html
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(35.466188, 139.622715);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }

</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

2011年9月26日月曜日

Excel VBA課題(5)

第7章ワイン販売管理(完成).xlsをベースに,販売データの入力を終了する際に,都度「end」という文字列を入力しなくても済むようにプログラムを変更せよ.

方針:
1回分の販売データの入力が終わったタイミングでデータ入力の終了・継続を確認するダイアログを表示し,その指示に従って動作を変更するようにする.

場所:
標準モジュール→販売リスト→Sub 入力()

sample code
Sub 入力()
    Dim hiduke As String
    ActiveWindow.NewWindow
    ActiveWindow.NewWindow
    Windows.Arrange xlArrangeStyleTiled
    Windows("第7章ワイン販売管理(完成).xls:2").Activate
    Worksheets("得意先リスト").Select
    Windows("第7章ワイン販売管理(完成).xls:1").Activate
    Worksheets("商品リスト").Select
    Windows("第7章ワイン販売管理(完成).xls:3").Activate
    If Range("C6").Value = "" Then
        Range("C6").Select
    Else
        Range("C5").Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Select
    End If
    
    Dim flag As Integer
    flag = 0
    
    Do While ActiveCell.Offset(0, -1).Value <> ""
        hiduke = InputBox("日付を入力してください")
        If hiduke = "" Then
            Exit Do
        Else
            ActiveCell.FormulaR1C1 = hiduke
            ActiveCell.Offset(0, 1).Range("A1").Select
            ActiveCell.FormulaR1C1 = InputBox("得意先コードを入力してください")
            ActiveCell.Offset(0, 2).Range("A1").Select
            ActiveCell.FormulaR1C1 = InputBox("商品コードを入力してください")
            ActiveCell.Offset(0, 4).Range("A1").Select
            ActiveCell.FormulaR1C1 = InputBox("数量を入力してください")
            ActiveCell.Offset(1, -7).Range("A1").Select
        End If
        
        flag = MsgBox("入力を終了しますか?", vbYesNo + vbQuestion, "終了確認")
        If flag = "6" Then
            Exit Do
        End If
    
    Loop
    Windows("第7章ワイン販売管理(完成).xls:2").Activate
    ActiveWindow.Close
    Windows("第7章ワイン販売管理(完成).xls:1").Activate
    ActiveWindow.Close
    ActiveWindow.WindowState = xlMaximized
End Sub