使用flash網路攝影機拍照的簡單實踐

來源:互聯網
上載者:User

開啟Flash CS3,建立一個Flash檔案(Script 2.0)。命名為pagea.fla

第一步:      在庫中建立一個視頻元件,類型選擇:視頻(受 ActionScript 控制)。      按F11開啟庫面板,右鍵空白地方出現一個快顯功能表,選擇“建立視頻”,隨便起個名字。

第二步:      將視頻元件拖到情境中,並調整尺寸到想要的大小。並起名為“camera”。同時在該圖層放置兩個Button,分別命名為“btnCamera”和“btnUpload”。

第三步:      建立一個圖層,命名為“代碼層”    點擊時間軸第一幀,按F9開啟代碼面板,粘貼如下代碼:

  Jscript代碼   //camera是在情境中一個Video執行個體          //注意如果要想擷取自己想要拍照大小,先做一個你想要大小的FLV檔案,然後video選Embedded          camera.clear();                                   //網路攝影機控制對象          var cam:Camera = Camera.get();          if ( cam  == null){             //code here if client no camera installed          }          //init variable          photow = new Number(160);          photoh = new Number(120);                   cam.setMode(photow, photoh, 10, true);          camera.attachVideo(cam); //綁定網路攝影機視頻流到video                   //該對象用於實現發送資料到網頁可get或post          var lv:LoadVars;          lv = new LoadVars();                                     //當按下拍照按紐          btnCamera.onRelease = function ()          {              //擷取當前視頻畫片              saveCamera();             //...          };          //toolbar.btnCameraRe.onRelease = function(){              //  ...              //saveCamera();          //}          function saveCamera(){               //建立一個bitmapdate對象並擷取video上的映像資訊              lv.bm = new flash.display.BitmapData(photow, photoh,true, 0);                 lv.bm.draw(camera);               //photoPreview是在情境中的一個Movie clip執行個體,用於輸出bitmapdate實現照片預纜              var tempObj = _root.createEmptyMovieClip("photo", 100);       tempObj._x = 300;       tempObj._y = 40;          tempObj.attachBitmap(lv.bm, 1);              }                   //上傳照片到伺服器          btnUpload.onRelease = function(){                   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.