在 Haxe 中使用网络摄像头输出填充 MovieClip
我正在尝试使用 Haxe 构建一个简单的 Flash SWF,以显示网络摄像头的输出。我希望 SWF 可以嵌入,并且大小可以在 HTML 中确定。所以我的 HTML 看起来像:
<html>
<head><title>Web cam</title></head>
<body bgcolor="#dddddd">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
id="haxe"
align="middle"
width="640" height="480">
<param name="movie" value="webcam.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="exactfit" />
<param name="bgcolor" value="#ffffff"/>
<embed src="webcam.swf"
width="640" height="480"
bgcolor="#ffffff"
name="haxe"
quality="high"
align="middle"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
/>
</object>
</body>
</html>
这应该放置一个大小为 640x480 的 webcam.swf。为了构建 webcam.swf
,我使用以下 Haxe 脚本:
class Webcam {
static function main() {
var mc : flash.display.MovieClip;
var rawvideo : flash.media.Video;
var cam:flash.media.Camera = flash.media.Camera.getCamera();
cam.setMode(320, 240, 24, false);
cam.setQuality(0, 100);
mc=flash.Lib.current;
var stage = flash.Lib.current.stage;
stage.scaleMode=flash.display.StageScaleMode.EXACT_FIT;
rawvideo = new flash.media.Video(Std.int(stage.width), Std.int(stage.height) );
rawvideo.attachCamera(cam);
if (cam!=null) {
mc.addChild(rawvideo);
} else {
trace("No Camera");
}
}
}
这将创建显示网络摄像头输出的 SWF 文件,但右侧和底部有一些大的白色带。我希望网络摄像头图像填充整个 Flash 对象。我做错了什么?
I'm trying to build a simple Flash SWF with Haxe that shows the output of my webcam. I want the SWF to be embeddable and the size to be determined in the HTML. So my HTML looks like:
<html>
<head><title>Web cam</title></head>
<body bgcolor="#dddddd">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
id="haxe"
align="middle"
width="640" height="480">
<param name="movie" value="webcam.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="exactfit" />
<param name="bgcolor" value="#ffffff"/>
<embed src="webcam.swf"
width="640" height="480"
bgcolor="#ffffff"
name="haxe"
quality="high"
align="middle"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
/>
</object>
</body>
</html>
This should put a webcam.swf of a size of 640x480. To build webcam.swf
I use the following Haxe script:
class Webcam {
static function main() {
var mc : flash.display.MovieClip;
var rawvideo : flash.media.Video;
var cam:flash.media.Camera = flash.media.Camera.getCamera();
cam.setMode(320, 240, 24, false);
cam.setQuality(0, 100);
mc=flash.Lib.current;
var stage = flash.Lib.current.stage;
stage.scaleMode=flash.display.StageScaleMode.EXACT_FIT;
rawvideo = new flash.media.Video(Std.int(stage.width), Std.int(stage.height) );
rawvideo.attachCamera(cam);
if (cam!=null) {
mc.addChild(rawvideo);
} else {
trace("No Camera");
}
}
}
This creates the SWF file that shows the webcam output but with some big white bands on the right and bottom. I want the webcam image to fill the entire Flash object. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有成功让你的代码在 640x480 下工作。
要使其在 320x240 下工作,请将以下行更改为:
并将
HTML 中的分辨率更改为 320x240。
I have had no success getting your code to work at 640x480.
To get it to work at 320x240 change the line:
to
And change the resolution to 320x240 in the HTML.