function CheckCam() { camArray = Camera.names; if (camArray.length >= 1) { temp_cam = Camera.get(); temp_cam.setMotionLevel(50, 100); source.myBox._visible = false; source.myBox.attachVideo(temp_cam); my_num = 0; temp_cam.onStatus = function () { if (temp_cam.muted) { sysInfo = "您拒绝了Flash访问摄像头,请刷新重试!"; shot_btn.enabled = false; shot_btn._alpha = 50; back_btn.enabled = false; back_btn._alpha = 50; submit_btn.enabled = false; submit_btn._alpha = 50; } // end if }; temp_cam.onActivity = function (mode) { ++my_num; if (my_num == 2) { source.myBox.attachVideo(null); source.myBox.clear(); execute_Call(); } else if (mode) { if (my_num == 1) { sysInfo = "正在检测摄像头是否被其它程序占用"; shot_btn.enabled = false; shot_btn._alpha = 50; back_btn.enabled = false; back_btn._alpha = 50; submit_btn.enabled = false; submit_btn._alpha = 50; executeCall(); } else { sysInfo = "其它程序正在使用您的摄像头\n请先关闭其它程序后刷新重试"; } // end else if } else { sysInfo = "其它程序正在使用您的摄像头\n请先关闭其它程序后刷新重试"; } // end else if }; } else if (camArray.length == 0) { sysInfo = "系统无法检测摄像头,请先确认您已\n经安装了摄像头并可以正常工作,然后刷新重试。"; } // end else if } // End of the function function executeCallback() { clearInterval(_root.interval); sysInfo = "其它程序正在使用您的摄像头\n请先关闭其它程序后刷新重试"; } // End of the function function executeCall() { _root.interval = setInterval(this, "executeCallback", 1000); } // End of the function function execute_ok() { clearInterval(_root.intervalId); sysInfo = "正在连接服务器,请稍候..."; nc = new NetConnection(); nc.connect(FlashComPath); nc.onStatus = function (info) { trace (info.code); if (info.code == "NetConnection.Connect.Success") { source.myBox._visible = true; setWebCam(); } else if (info.code != "NetConnection.Connect.Closed") { sysInfo = "连接服务器失败,暂时无法拍照,请您稍后再试。"; } // end else if }; } // End of the function function execute_Call() { _root.intervalId = setInterval(this, "execute_ok", 800); } // End of the function function setWebCam() { var _loc1 = Camera.get(); _loc1.setMode(180, 135, 25); _loc1.setQuality(512000, 90); source.myBox.attachVideo(_loc1); shot_btn.enabled = true; shot_btn._alpha = 100; back_btn.enabled = true; back_btn._alpha = 100; submit_btn.enabled = true; submit_btn._alpha = 100; sysInfo = "初始化完毕,可以进行拍贴"; } // End of the function CheckCam(); var url = _root.url; var FlashComPath = "rtmp://s1.maodao.com/Record"; sysInfo = "请点击【允许】激活视频设备。"; lv = new LoadVars(); _global.photox = 240; _global.photoy = 180; this.source.myBox._width = photox; this.source.myBox._height = photoy; this.source._width = photox; this.source._height = photoy; this.source.bord.loadMovie(url); onEnterFrame = function () { if (this.source.bord._width > 2) { this.source.bord._width = photox; this.source.bord._height = photoy; } // end if }; shot_btn.onRelease = shot_btn.onReleaseOutside = function () { source.myBox.attachVideo(null); shot_btn.enabled = false; shot_btn._alpha = 50; lv.bmap = new flash.display.BitmapData(240, 180, false, 0); lv.bmap.draw(source); dest2.attachBitmap(lv.bmap, 1); dest2._width = 180; sysInfo = "拍贴完毕,点击“重拍”或“保存”"; }; back_btn.onRelease = back_btn.onReleaseOutside = function () { setWebCam(); shot_btn.enabled = true; shot_btn._alpha = 100; }; submit_btn.onRelease = submit_btn.onReleaseOutside = function () { sysInfo = "正在保存图像,请稍候..."; shot_btn.enabled = false; shot_btn._alpha = 50; back_btn.enabled = false; back_btn._alpha = 50; submit_btn.enabled = false; submit_btn._alpha = 50; go = function () { clearInterval(s); delete _root.cam; image = ""; i = lv.bmap.height; j = lv.bmap.width; for (y = i; y >= 0; y--) { for (x = 0; x < j; x++) { color = lv.bmap.getPixel(x, y).toString(16); if (color.length == 5) { color = "0" + color; } // end if image = image + (color + "|"); } // end of for } // end of for lv.height = i; lv.width = j; lv.image = image; lv.send("tzx_action.shtm", "_self", "post"); }; s = setInterval(go, 500); }; alphaCtrl.alphaBar.onPress = function () { this.startDrag(0, 0, 0, 0, 130); }; alphaCtrl.alphaBar.onMouseMove = function () { source.bord._alpha = -100 * this._y / 130 + 100; picAlpha = int(source.bord._alpha); }; alphaCtrl.alphaBar.onRelease = alphaCtrl.alphaBar.onReleaseOutside = function () { this.stopDrag(); };