addchild not displaying content

Posted by Rajeev on Stack Overflow See other posts from Stack Overflow or by Rajeev
Published on 2010-12-24T11:03:47Z Indexed on 2010/12/24 20:54 UTC
Read the original article Hit count: 240

Filed under:
|
|
|
|

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;

 } 
 }
 }

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3