访问 div 中的相机
下面为什么相机没有出现在 div 中。我在这里做错了什么吗
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="test" style="display:block;"></div>
<a href="#" onclick="document.getElementById('test').addBlock();">Call addBlock</a>
<script type="text/javascript">
swfobject.embedSWF('test.swf', 'test', '300', '300', '9.0.124', 'expressInstall.swf');
</script>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="300" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.media.*;
import flash.net.*;
public static var cam:Camera = Camera.getCamera();
public static var video:Video = new Video(10, 20);
private function init():void
{
ExternalInterface.addCallback('addBlock', addBlock);
}
private function addBlock():void
{
//Alert.show("addBlock called");
if(cam != null)
{
cam.setMode(640, 480, 30);
video.attachCamera(cam);
addChild(video);
}
else
{
trace("No Camera Detected");
Alert.show("No Camera Detected");
}
}
]]>
</mx:Script>
</mx:Application>
In the following why is that the camera does not show up in the div.Is that am i doing anything wrong here
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="test" style="display:block;"></div>
<a href="#" onclick="document.getElementById('test').addBlock();">Call addBlock</a>
<script type="text/javascript">
swfobject.embedSWF('test.swf', 'test', '300', '300', '9.0.124', 'expressInstall.swf');
</script>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="300" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.media.*;
import flash.net.*;
public static var cam:Camera = Camera.getCamera();
public static var video:Video = new Video(10, 20);
private function init():void
{
ExternalInterface.addCallback('addBlock', addBlock);
}
private function addBlock():void
{
//Alert.show("addBlock called");
if(cam != null)
{
cam.setMode(640, 480, 30);
video.attachCamera(cam);
addChild(video);
}
else
{
trace("No Camera Detected");
Alert.show("No Camera Detected");
}
}
]]>
</mx:Script>
</mx:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先我要做的是确保 Flash 确实被嵌入。如果 Javascript 工作正常,那么这里可能存在一些问题。首先,我并不肯定,但我认为您不希望将相机连接到视频对象,而是连接到视频显示器:
然后做:
第二件事是,如果您使用的是 Mac,则标准getCamera() 函数并非 100% 都有效。我建议您定义自己的获取相机函数,该函数应如下所示:
基本上,某些 Mac 有一个默认相机,该相机位于一个奇怪的位置,标准 getCamera 调用不起作用。这个应该有帮助。祝你好运!
First what I would do is to make sure that the Flash is actually being embedded. If it is the case that the Javascript is working correctly then there are a few possible issues here. First I'm not positive but I would think that you wouldn't want to be attaching the camera to a video object, but instead to a video display:
And then do:
The second thing is that if you are using a Mac the standard getCamera() function doesn't work 100% of the time. What I would recommend you do is define your own get camera function which should look something like this:
Basically some Macs have a default camera which is located in a weird place where the standard getCamera call doesn't work. This one should help. Good luck!