flex设置舞台大小怎么弄?

wo_buhui 2012-12-20 01:50:32
打算在网页里用swf显示摄像头,但是这个摄像头的video无法控制大小

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="showCamera(event)">
<fx:Script>
<![CDATA[
import flash.net.FileReference;
import flash.net.URLRequest;

import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.graphics.ImageSnapshot;
import mx.graphics.codec.PNGEncoder;
import mx.rpc.http.HTTPService;


private var camera:Camera;
private var video:Video;
protected function showCamera(event:FlexEvent):void{


camera=Camera.getCamera();
if(camera!=null){
video=new Video(200,150);
video.attachCamera(camera);
video.x=0;
video.y=0;
myUI.addChild(video);
}else{
Alert.show("对不起,您没有摄像头!");
}
}
public function takePic(event:MouseEvent):void{
Alert.show("clicked");
var jpgSource:BitmapData= new BitmapData(video.width,video.height);
var myMatrix:Matrix=new Matrix();
jpgSource.draw(video,myMatrix);
var png:PNGEncoder = new PNGEncoder();
var imgbyte:ByteArray=png.encode(jpgSource);

var request:URLRequest = new URLRequest("http://127.0.0.1:8080/takePic/servlet/getPic");
var loader:Loader = new Loader();
request.data = imgbyte;
request.method = flash.net.URLRequestMethod.POST;
request.contentType = "application/octet-stream";
loader.load( request );

}

]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<mx:UIComponent width="200" height="150" id="myUI" />
<s:Button x="100" y="150" label="拍照" id="imgBtn" click="takePic(event)"/>
</s:Application>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>${title}</title>
<meta name="google" value="notranslate" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
// To use express install, set to playerProductInstall.swf, otherwise the empty string.
var xiSwfUrlStr = "${expressInstallSwf}";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
swfobject.embedSWF(
"${swf}.swf", "flashContent",
"200px", "180px",//<----------------------------这里有问题!!!!
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
// JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
swfobject.createCSS("#flashContent", "display:block;text-align:left;");



</script>
</head>

<body>
<div id="flashContent"></div>
</body>
</html>

1.以上有问题部分曾经为"${width}","${height}",但是这样做swf会铺满整个屏幕。
2.我把宽度改为400px,高度改为300px,这样就可以显示如下


3.但是如果把宽度改为200,高度改为180的话,就只能如下


怎么改了大小那个flash安全设置的东西就出不来了??
...全文
740 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2012-12-25
  • 打赏
  • 举报
回复
这个没有用过,只能帮你顶一顶。
peijie1989 2012-12-20
  • 打赏
  • 举报
回复
flex学的不多:[SWF(width="1000",height="750",backgroundColor="#D6E3F7",frameRate="100")] 我们知道使用Flash CS3 /Flash CS4 创建Flash 项目可以很方便的在项目属性面板上设置项目的舞台的大小,但当我们用Flex / Flash Builder 来做Flash 时候就没有直观的属性来设置舞台大小了。
wo_buhui 2012-12-20
  • 打赏
  • 举报
回复
怎么没人回复呢,自己顶一个。。。

879

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 ColdFusion
社区管理员
  • ColdFusion社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧