addchild不显示内容

发布于 2024-10-09 05:40:05 字数 1980 浏览 0 评论 0原文

在下面的代码中我没有任何错误,但为什么是 addchild(video);即网络摄像头捕获的视频不显示

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


<mx:Script>
<![CDATA[
import org.com.figurew;
import mx.controls.Button;
import mx.controls.Alert;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.media.*;
import flash.net.*;


public function addBody():void
{

var ret:Number = figurew.getInstance().getparam();
if( ret == 1)
{
 Alert.show("Camera detected");

}
if(ret == 0)
{
 Alert.show("No camera detected");
} 
var cam:Camera =  Camera.getCamera();
if(cam != null)
{ 
 cam.setMode(640, 480, 30);
 var video:Video = new Video(30, 40);
 video.attachCamera(cam);

 addChild(video);


}
else
{

 trace("No Camera Detected");

 }

}


  ]]>

 </mx:Script>
 <mx:Button label="Test camera" click="addBody();"  x="99" y="116"/>

 </mx:Application >

figurew.as

 package org.com
 {
 import flash.display.InteractiveObject;
 import flash.display.Sprite;
 import flash.media.*;
 import flash.net.*;


 public class figurew extends Sprite
 {
  public function figurew()
  {
 //getparam();
 var cam:Camera =  Camera.getCamera();
 if(cam != null)
 { 
  cam.setMode(640, 480, 30);
  var video:Video = new Video(300, 450);
  video.attachCamera(cam);

  addChild(video);


 }
else
{

 trace("No Camera Detected");

}

}
public function getparam():Number
{ 
 var cam:Camera =  Camera.getCamera();
 if(cam != null)
 { 
 cam.setMode(640, 480, 30);
 var video:Video = new Video(300, 450);
 video.attachCamera(cam);

 addChild(video);
 return 1;

 }
 else
 {
 return 0;
 trace("No Camera Detected");

 }
  }
 private static var _instance:figurew = null;

 public static function getInstance():cldAS
 {
 if(_instance == null)
 {
 trace("No instance found");
 _instance = new cldAS();
 }
 return _instance;

 } 
 }
 }

In the following code i dont have any error but why is that the addchild(video); i.e, the the video captured by webcam is not displayed

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


<mx:Script>
<![CDATA[
import org.com.figurew;
import mx.controls.Button;
import mx.controls.Alert;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.media.*;
import flash.net.*;


public function addBody():void
{

var ret:Number = figurew.getInstance().getparam();
if( ret == 1)
{
 Alert.show("Camera detected");

}
if(ret == 0)
{
 Alert.show("No camera detected");
} 
var cam:Camera =  Camera.getCamera();
if(cam != null)
{ 
 cam.setMode(640, 480, 30);
 var video:Video = new Video(30, 40);
 video.attachCamera(cam);

 addChild(video);


}
else
{

 trace("No Camera Detected");

 }

}


  ]]>

 </mx:Script>
 <mx:Button label="Test camera" click="addBody();"  x="99" y="116"/>

 </mx:Application >

figurew.as

 package org.com
 {
 import flash.display.InteractiveObject;
 import flash.display.Sprite;
 import flash.media.*;
 import flash.net.*;


 public class figurew extends Sprite
 {
  public function figurew()
  {
 //getparam();
 var cam:Camera =  Camera.getCamera();
 if(cam != null)
 { 
  cam.setMode(640, 480, 30);
  var video:Video = new Video(300, 450);
  video.attachCamera(cam);

  addChild(video);


 }
else
{

 trace("No Camera Detected");

}

}
public function getparam():Number
{ 
 var cam:Camera =  Camera.getCamera();
 if(cam != null)
 { 
 cam.setMode(640, 480, 30);
 var video:Video = new Video(300, 450);
 video.attachCamera(cam);

 addChild(video);
 return 1;

 }
 else
 {
 return 0;
 trace("No Camera Detected");

 }
  }
 private static var _instance:figurew = null;

 public static function getInstance():cldAS
 {
 if(_instance == null)
 {
 trace("No instance found");
 _instance = new cldAS();
 }
 return _instance;

 } 
 }
 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-10-16 05:40:05

我没有看到您设置主应用程序的视频子级的高度或宽度的地方。这可能是一个问题。

脚本标签内有一个 MX Button 标签。我怀疑这会导致编译错误。因此,您可能正在查看代码的“旧”版本。修复错误并重新编译并重新启动。

I see no place where you set a height or width of the video child of your main application. That may be an issue.

You have an MX Button tag inside the script tag. I suspect this will cause a compilation error. So it is possible that you're viewing an "old" Version of your code. Fix the errors and recompile and relaunch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文