# Web cam challenge (as3)

**URL:** <https://forum.kirupa.com/t/web-cam-challenge-as3/260293>\
**Category:** Uncategorized\
**Created:** [May 14, 2008, 7:15am UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293 "2008-05-14T07:15:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![maloola](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@maloola](https://forum.kirupa.com/u/maloola)\
**Post date:** [May 14, 2008, 7:15am UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/1 "2008-05-14T07:15:56Z")

</div>

i currently have a web cam class, one instance of it and a web cam image on stage.  
i want to create two images on stage, one mirrors the other, only bigger.

i tried:

[SIZE=1]var bitmapData:BitmapData = new BitmapData(webcamIns.width+50, [/SIZE][SIZE=1]webcamIns[/SIZE][SIZE=1].height+50, true, 0xffffff);  
bitmapData.draw([/SIZE][SIZE=1]webcamIns[/SIZE][SIZE=1]);  
var bitmap:Bitmap = new Bitmap(bitmapData);  
addChild(bitmap); [/SIZE]

that doesn’t work!!

PLEASE HELP:puzzled:

---

<div class="post-metadata">

**Author:** ![maloola](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@maloola](https://forum.kirupa.com/u/maloola)\
**Post date:** [May 14, 2008, 12:45pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/2 "2008-05-14T12:45:18Z")

</div>

a prize to my rescuer!!

somebody?..

---

<div class="post-metadata">

**Author:** ![Jerryscript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jerryscript/32/451_2.png) [@Jerryscript](https://forum.kirupa.com/u/Jerryscript)\
**Post date:** [May 14, 2008, 2:16pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/3 "2008-05-14T14:16:19Z")

</div>

You need to do this in an event listener, enterframe, setInterval, setTimeout, or one of the camera activity listeners.

If you only run it once at load time, the webcam hasn’t initiated yet, so you wont get an image. Even if you wait till the webcam has initialized, you will only get a single static image without the event listener loop.

---

<div class="post-metadata">

**Author:** ![maloola](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@maloola](https://forum.kirupa.com/u/maloola)\
**Post date:** [May 14, 2008, 2:39pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/4 "2008-05-14T14:39:26Z")

</div>

the problem is that even with adding an event listener, the image doesn’t appear, as if the “copying” of it can’t be done. i think it because i’m using a class for it, but my webcam class extends Video - a display object…

for now i’m using two instances of my class… not a really good solution since i don’t need all the functionalities of the class for both of the images.

---

<div class="post-metadata">

**Author:** ![mpelland](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mpelland](https://forum.kirupa.com/u/mpelland)\
**Post date:** [May 14, 2008, 2:43pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/5 "2008-05-14T14:43:42Z")

</div>

write the video data from the webcam to bitmaps on the stage, use a matrix to flip one of the bitmap

---

<div class="post-metadata">

**Author:** ![maloola](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@maloola](https://forum.kirupa.com/u/maloola)\
**Post date:** [May 14, 2008, 2:56pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/6 "2008-05-14T14:56:10Z")

</div>

mpelland, how can i use a matrix to flip one of the bitmap?  
thanks

---

<div class="post-metadata">

**Author:** ![mpelland](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mpelland](https://forum.kirupa.com/u/mpelland)\
**Post date:** [May 14, 2008, 3:13pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/7 "2008-05-14T15:13:38Z")

</div>

i would say that you can create a matrix and set the scale on it then apply that when drawing the bitmapdata

[AS]var m:Matrix = new Matrix();  
m.scale(-1, 1);  
var outputFlipped:BitmapData = new BitmapData( 320, 240 );  
outputFlipped.draw(bmd, m); // bmd would be the original bitmap data[/AS]

---

<div class="post-metadata">

**Author:** ![maloola](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@maloola](https://forum.kirupa.com/u/maloola)\
**Post date:** [May 14, 2008, 3:30pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/8 "2008-05-14T15:30:43Z")

</div>

i think i can’t get to the camera’s original bitmapData, in the webcam class i have a camera that is added to the video.

---

<div class="post-metadata">

**Author:** ![Jerryscript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jerryscript/32/451_2.png) [@Jerryscript](https://forum.kirupa.com/u/Jerryscript)\
**Post date:** [May 14, 2008, 9:25pm UTC](https://forum.kirupa.com/t/web-cam-challenge-as3/260293/9 "2008-05-14T21:25:40Z")

</div>

The camera object is what you draw to your flipped bitmapData object:

myBitmapData.draw(camera, flippedMatrix);
