2 Replies Latest reply on Dec 13, 2012 8:39 AM by jwbell

    Problems using camera - Flash CS4

      • All updates are installed
      • Please give us more information about your Creative environment:
        • Flash 10.0.2 for CS4
        • Mac OSX v10.7


      I am following the ActionScript 3.0 for Adobe Flash CS4 Professional - Classroom in a Book


      I am in Lesson 12 where it references accessing the user's camera to display an image caught by the camera.  The intent of the lesson is that once the image is loaded on the screen, filters can be applied to it.  The issue I have is that no image is displayed on my screen.  I have been over the code closely (the completed file that comes pre-loaded ready to go did not work).  I have loaded facetime and I have been to www.testmycam.com and my camera works fine in both instances.  The dialog box comes and asks me to allow or deny.  I of course click ALLOW.  I am at a loss.  The code is below.  Any help would be appreciated.


      import fl.ik.*;

      import fl.events.SliderEvent;

      import flash.media.Camera;

      import flash.media.Video;




      var arm0:IKArmature = IKManager.getArmatureAt(0);

      var rt0:IKJoint = arm0.rootJoint;

      var jt0:IKJoint = rt0.getChildAt(0).getChildAt(0).getChildAt(0);

      var mover0:IKMover = new IKMover(jt0, jt0.position);



      var fx1:Sound = new Sound();

      fx1.load(new URLRequest("robotArm.mp3"));

      var channel1:SoundChannel = new SoundChannel;                                                                                            



      var fx2:Sound = new Sound();

      fx2.load(new URLRequest("click.mp3"));

      var channel2:SoundChannel = new SoundChannel;



      var camera:Camera=Camera.getCamera();

      var video:*;



      if(camera != null) {

                video = new Video(160, 120);



                trace("camera is ok");

      } else {

                trace("There is no recognized camera connected to your computer.");

                video = new AltVid();





      snapshot_btn.addEventListener(MouseEvent.CLICK, onSnapShot);



      function onSnapShot(e:MouseEvent):void {

                stage.addEventListener(Event.ENTER_FRAME, moveDown);

                snapshot_btn.visible = false;

                channel1 = fx1.play();




      function moveDown(e:Event) {

                if(jt0.position.y < 305) {

                          var pt0:Point = new Point(jt0.position.x + 5, jt0.position.y + 5);


                } else {


                          channel2 = fx2.play();

                          channel1 = fx1.play();

                             stage.removeEventListener(Event.ENTER_FRAME, moveDown);

                          stage.addEventListener(Event.ENTER_FRAME, moveUp);





      function moveUp(e:Event):void {

                if(jt0.position.y > 165) {

                          var pt0:Point = new Point(jt0.position.x - 5, jt0.position.y - 5);


                } else {

                          stage.removeEventListener(Event.ENTER_FRAME, moveUp);

                          snapshot_btn.visible = true;







        • 1. Re: Problems using camera - Flash CS4
          esdebon Level 4

          Detect a web cam in windows is different to detect a webcam in mac




          function activaWebcam(e:MouseEvent):void{

              //trace("webcam active");

              var index = 0; //for windows - default value  


              //Searching index of the webcam in Mac

              for (var i=0 ;i< Camera.names.length;i++) {

                  if ( Camera.names[i] == "USB Video Class Video" ) {

                      index = i;



              cam = Camera.getCamera(index);



          • 2. Re: Problems using camera - Flash CS4
            jwbell Level 1



            Thanks for the quick, great help.  That worked great.  You think they would have mentioned that in the book.  If they did, I overlooked it.  You are great.