zoukankan      html  css  js  c++  java
  • flash场影控制

    var radar_offset:Number=0;
    var currentid:Number=0;
    var topid:Number=1;
    var hotspots:Array=new Array;

    // Create container movieclip
    var vr:MovieClip = _root.createEmptyMovieClip("vr", 1);
    // prevent access to "real" root
    vr._lockroot=true;

    function clearHotspots() {
     var mc:MovieClip;
     var i:Number;
     for (i=0;i<hotspots.length;i++) {
      mc=hotspots[i];
      mc.removeMovieClip();
     }
     hotspots=new Array();
    }

    function loadPanorama(id:Number) {
     // Create a Movieclip loader
     var myLoader = new MovieClipLoader();
     var myListener = new Object();
     
     // remove old Hotspots
     clearHotspots();

     myListener.onLoadStart = function () {
      var filename:String;
     // Set the dimentions and position of the pano
      vr.window_width=470;
      vr.window_height=380;
      vr.window_x=120;
        vr.window_y=10;
     // change autorotation 
        vr.autorotate=0.5;
        vr.autorotate_delay=20;
      
      // add a preview bar...
      var my_fmt:TextFormat = new TextFormat();
      my_fmt.bold = true;
      my_fmt.font = "Arial";
      my_fmt.size = 12;
      my_fmt.color = 0xffffff;
      _root.createTextField("pretxt",10,170,40,200,20);
      _root.pretxt.setNewTextFormat(my_fmt);
      _root.pretxt.selectable = false;
      _root.pretxt.text = "Loading...";
      _root.createEmptyMovieClip("prebar",21);
     };

     myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
      // update progress bar
      var x1:Number,x2:Number,y1:Number,y2:Number;
      _root.pretxt.text = "Loading... " + Math.floor(100*loadedBytes/totalBytes) + " %";
      _root.prebar.clear();
      _root.prebar.beginFill(0x0000FF, 30);
      _root.prebar.lineStyle(2, 0x000080, 100);

      x1=_root.pretxt._x;
      x2=x1 + 180 * loadedBytes/totalBytes;
      y1=_root.pretxt._y+20;
      y2=y1+10;
      
      _root.prebar.moveTo(x1, y1);
      _root.prebar.lineTo(x2, y1);
      _root.prebar.lineTo(x2, y2);
      _root.prebar.lineTo(x1, y2);
      _root.prebar.lineTo(x1, y1);
      _root.prebar.endFill();
      
     };
     
     myListener.onLoadComplete = function () {
      // remove progress bar
      _root.pretxt.removeTextField();
      _root.prebar.removeMovieClip();
     };

     
     myListener.onLoadInit = function () {
      setupPanorama(currentid);
      // Add another hotspot to position pan 0, tilt -90 (nadir) without rollover effect
      var hs_p2q:MovieClip=_root.attachMovie("pano2qtvr_lib","hs_textmc2",10200);
      hs_p2q.onRelease=function() {
       _root.getURL('http://www.pano2qtvr.com','_blank');
      }
      vr.pano.addHotspot('p2q',0,-90,hs_p2q);
      // add hotspots to a list to clear them
      hotspots.push(hs_p2q);
      compass.fov._visible=true;
     };

     // add the Listener
     myLoader.addListener(myListener);
     
     // set the parameters for the different panoramas
     if (id==1) {
      filename="park.swf";
      radar_offset=-10;
      compass._x=map._x+map.bt1._x;
      compass._y=map._y+map.bt1._y;
     }
     if (id==2) {
      filename="pavilion.swf";
      radar_offset=110;
      compass._x=map._x+map.bt2._x;
      compass._y=map._y+map.bt2._y;
     }
     if (id==3) {
      filename="fountain.swf";
      compass._x=map._x+map.bt3._x;
      compass._y=map._y+map.bt3._y;
      radar_offset=210;
     }
     // remove the radar during loading
     compass.fov._xscale=0;
     compass.fov._yscale=0;
     compass.fov._visible=false;

     // ... and finally load the pano!
     myLoader.loadClip(filename, vr);
     currentid=id;
     
    }

    function addNextPanoHotspot(aid:String,apan:Number,atilt:Number,hstext:String,nid:Number) {
     // Add first Hotspot
     topid++;
     var hs_textmc1:MovieClip=_root.attachMovie("hs_lib","hs_textmc1",10000 + topid);

     // Set the text of this instance
       hs_textmc1.hstext.text=hstext;
     // Add a action to this instance
       hs_textmc1.onRelease=function() {
      loadPanorama(nid);
       }
     // Rollover effect
       hs_textmc1.hstext._visible=false;
       hs_textmc1.onRollOver=function() {
      hs_textmc1.hstext._visible=true;
       }
       hs_textmc1.onRollOut=function() {
      hs_textmc1.hstext._visible=false;
       }
     vr.pano.addHotspot(aid,apan,atilt,hs_textmc1);
     // add hotspots to a list to clear them
     hotspots.push(hs_textmc1);
    }

    function setupPanorama(id:Number) {
     // reset the topid
     topid=0;
     // add the hotspots for to the other panoramas
     if (id==1) {
      addNextPanoHotspot("pavilion", 69, 0, "Pavilion",2);
      addNextPanoHotspot("fountain", 170, 0, "Fountain",3);
     }
     if (id==2) {
      addNextPanoHotspot("park", 115, 0, "Park",1);
      addNextPanoHotspot("fountain", 54, 0, "Fountain",3);
     }
     if (id==3) {
      addNextPanoHotspot("park", 120, 0, "Park",1);
      addNextPanoHotspot("pavilion", 144, 0, "Pavilion",2);
     }
    }


    // attach the border. The border is "higher" then the restm so it is in the forgound
    var border:MovieClip=_root.attachMovie("border_lib","border",20001,{_alpha:100});

    // add the map
    var map:MovieClip=_root.attachMovie("map","map",20005,{_x:0,_y:100});

    // connect the buttons in the map
    map.bt1.onPress=function () {
     loadPanorama(1);
    }
    map.bt2.onPress=function () {
     loadPanorama(2);
    }
    map.bt3.onPress=function () {
     loadPanorama(3);
    }

    // ... and the rader is even higher...
    var compass:MovieClip=_root.attachMovie("compass_lib","compass",20010,{_x:60,_y:200,_alpha:50});

    compass.fov._xscale=0;
    compass.fov._yscale=0;
    compass._visible=true;
    compass.fov._visible=false;

    // update the shape of the rader on each frame
    _root.onEnterFrame=function() {
     compass.fov._rotation=-(vr.pano.getPan()+radar_offset);
     compass.fov._xscale=100*Math.tan(vr.pano.getFov()*Math.PI/360);
     compass.fov._yscale=100*Math.cos(vr.pano.getTilt()*Math.PI/180);
    }

    // load the pavilion pano first
    loadPanorama(2);


     

  • 相关阅读:
    document.documentElement.clientHeight 和 $(window).height() 无法正确获取页面可视区高度
    day05python-fullstack-数据类型
    python-day05-fullstack-#判断数字,推出,使用占位符,格式化输出
    np.random.rand()函数与randn()
    numpy.dot
    Python数据分析----Matplotlib
    day03-python运算符----比较/赋值/逻辑/成员
    全栈开发-day02-python不明就里
    全栈开发-day01-字符编码与计算机容量
    matplotlib面向对象函数画图介绍:
  • 原文地址:https://www.cnblogs.com/hhq80/p/1517921.html
Copyright © 2011-2022 走看看