チェンジセット 2058

差分発生行の前後
無視リスト:
コミット日時:
2008/12/16 00:28:25 (3 年前)
コミッタ:
uranodai
ログメッセージ:

--

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/StreetView/trunk/samples/Sample-app.xml

    r1227 r2058  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <application xmlns="http://ns.adobe.com/air/application/1.0"> 
     2<application xmlns="http://ns.adobe.com/air/application/1.5"> 
    33 
    44<!-- Adobe AIR Application Descriptor File Template. 
  • as3/StreetView/trunk/samples/Sample.as

    r1227 r2058  
    22{ 
    33        import flash.display.Sprite; 
     4        import flash.display.StageAlign; 
     5        import flash.display.StageScaleMode; 
     6        import flash.events.Event; 
    47        import flash.events.KeyboardEvent; 
    58        import flash.ui.Keyboard; 
    69         
    710        import uranodai.streetview.StreetView; 
     11        import uranodai.streetview.data.LocationData; 
     12        import uranodai.streetview.data.Shibuya; 
    813 
    9         [SWF(width="300",height="350",frameRate="30",backgroundColor="#FFFF00")] 
     14        [SWF(width="500",height="550",frameRate="30",backgroundColor="#FFFF00")] 
    1015 
    1116        public class Sample extends Sprite 
     
    1520                public function Sample() 
    1621                { 
    17                         streetView = new StreetView(300,300); 
    18                         streetView.load("http://localhost/Workspace/StreetView/app/"); 
     22                        stage.scaleMode = StageScaleMode.NO_SCALE; 
     23                        stage.align = StageAlign.TOP_LEFT; 
     24                         
     25                        var location:LocationData = new Shibuya().minamiguchi; 
     26                         
     27                        streetView = new StreetView(500,500); 
     28                        streetView.load(location.lat, location.lon); 
    1929                        addChild(streetView); 
     30                         
     31                        stage.addEventListener(Event.RESIZE, onResize); 
    2032                         
    2133                        stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); 
     
    2537                { 
    2638                        if(e.keyCode == Keyboard.UP){ 
    27                                 //進む 
     39                                //進む    
    2840                                streetView.goFront(); 
    2941                        } 
    3042                } 
    3143                 
     44                private function onResize(e:Event):void 
     45                { 
     46                        streetView.resize(stage.stageWidth, stage.stageHeight-50); 
     47                } 
     48                 
    3249        } 
    3350} 
  • as3/StreetView/trunk/src

    • 属性の設定値: svn:ignore (登録)
      Sample-app.xml

      Sample.as
  • as3/StreetView/trunk/src/uranodai/streetview/StreetView.as

    r1227 r2058  
    11package uranodai.streetview 
    22{ 
     3        import flash.display.Bitmap; 
     4        import flash.display.BitmapData; 
    35        import flash.display.Sprite; 
     6        import flash.events.Event; 
    47        import flash.html.HTMLLoader; 
    58        import flash.net.URLRequest; 
     9         
     10        import uranodai.streetview.event.StreetViewEvent; 
    611 
    712        public class StreetView extends Sprite 
    813        { 
     14                public static const APP_URL:String = "http://uranodai.com/docs/streetview/"; 
     15                 
    916                private var html:HTMLLoader; 
     17                 
     18                private var bitmap:Bitmap; 
     19                private var bitmapData:BitmapData; 
    1020                 
    1121                private var _lat:Number; 
    1222                private var _lon:Number; 
     23                 
     24                private var w:int; 
     25                private var h:int; 
    1326                 
    1427                public function StreetView(w:int, h:int) 
     
    1730                        html.width = w; 
    1831                        html.height = h; 
     32                         
     33                        this.w = w; 
     34                        this.h = h; 
    1935                } 
    2036                 
    21                 public function load(appUrl:String="", latitude:Number=42.345573, longitude:Number=-71.098326):void 
     37                public function load(latitude:Number=42.345573, longitude:Number=-71.098326, appUrl:String=APP_URL):void 
    2238                { 
    2339                        var req:URLRequest = new URLRequest(); 
     
    3046                                html.window.load(latitude, longitude); 
    3147                        } 
     48                        html.window.onYawChanged = function(yaw:Number):void 
     49                        { 
     50                                //trace("yaw", yaw); 
     51                        } 
     52                        html.window.onPitchChanged = function(pitch:Number):void 
     53                        { 
     54                                //trace("pitch", pitch); 
     55                        } 
     56                        html.window.onZoomChanged = function(zoom:Number):void 
     57                        { 
     58                                //trace("zoom", zoom); 
     59                        } 
     60                        html.window.onInitialized = function(location:Object):void 
     61                        { 
     62                                _lat = String(location.latlng).split(", ")[0].toString().split("(")[1]; 
     63                                _lon = String(location.latlng).split(", ")[1].toString().split(")")[0]; 
     64                                //trace(_lat, _lon); 
     65                                //trace(location.pov); 
     66                                //trace(location.description); 
     67                                //trace(location.panoId); 
     68                        } 
    3269                         
    3370                        _lat = latitude; 
    3471                        _lon = longitude;        
     72                         
     73                        bitmapData = new BitmapData(w, h); 
     74                        bitmapData.draw(html); 
     75                        bitmap = new Bitmap(bitmapData, "auto", true); 
     76                        addChild(bitmap); 
     77                         
     78                        addEventListener(Event.ENTER_FRAME, onEnterFrame); 
     79                } 
     80                 
     81                private var _loaded:Boolean = false; 
     82                 
     83                private function onEnterFrame(e:Event):void 
     84                { 
     85                        if(html.window.StreetView != undefined && _loaded == false){ 
     86                                _loaded = true; 
     87                                dispatchEvent(new StreetViewEvent(StreetViewEvent.ON_LOAD)); 
     88                        } 
     89                         
     90                        bitmapData.draw(html); 
     91                } 
     92                 
     93                public function getLat():Number 
     94                { 
     95                        return _lat; 
     96                } 
     97                 
     98                public function getLng():Number 
     99                { 
     100                        return _lon; 
    35101                } 
    36102                 
     
    42108                { 
    43109                        return html.window.StreetView.currentYaw; 
     110                } 
     111                public function getZoom():Number 
     112                { 
     113                        return html.window.StreetView.currentZoom; 
    44114                } 
    45115                 
     
    87157                        html.window.zoomOut(); 
    88158                } 
     159                 
     160                public function scaleTo(scale:Number):void 
     161                { 
     162                         
     163                        bitmap.scaleX = scale; 
     164                        bitmap.scaleY = scale; 
     165                        bitmap.x = (1-scale)*html.width/2; 
     166                        bitmap.y = (1-scale)*html.height/2; 
     167                         
     168                        //Tweener.addTween(bitmap, {scaleX:scale, scaleY:scale, x:(1-scale)*html.width/2, y:(1-scale)*html.height/2, time:0.5, transition:"easeOutCubic" }); 
     169                } 
     170                 
     171                public function update(lat:Number, lon:Number):void 
     172                { 
     173                        _lat = lat; 
     174                        _lon = lon; 
     175                        html.window.load(lat, lon); 
     176                } 
     177                 
    89178                public function resize(w:int, h:int):void 
    90179                { 
     
    92181                        html.height = h; 
    93182                        html.window.load(_lat, _lon); 
     183                         
     184                         
     185                        bitmapData = new BitmapData(w, h); 
     186                        bitmap.bitmapData = bitmapData; 
    94187                } 
    95188        }