Nazdarek. Vytvoril som si script pre zachytenie obrazka z webky a nasledne ulozenie do PC za pomoci casovaca:
Kód:
import flash.media.Camera;
import flash.media.Video;
import com.adobe.images.JPGEncoder;
import com.adobe.images.BitString;
import flash.net.FileReference;
import flash.events.MouseEvent;
import flash.display.BitmapData;
import flash.utils.ByteArray;
import flash.events.TimerEvent;
import flash.utils.Timer;
var webCam:Camera = Camera.getCamera();
var vid:Video = new Video(320, 240);
var reference:FileReference = new FileReference();
vid.smoothing = true;
vid.attachCamera(webCam);
vid.x = 10;
vid.y = 20;
addChild(vid);
timer_bt.addEventListener(MouseEvent.CLICK, complet);
timer_bt.addEventListener(MouseEvent.CLICK, ShortTimer);
// Casovac
function ShortTimer(mouseEveten:MouseEvent)
{
var count:Number = 5;
pole.text = String(count);
var myTimer:Timer = new Timer(1000,count);
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, complet);
myTimer.start();
function countdown(event:TimerEvent) {
pole.text = String((count)-myTimer.currentCount);
}
function complet(event:TimerEvent) {
var imgName="obrazok.jpg";
// Create image
var bitmap:BitmapData = new BitmapData(vid.width, vid.height);
bitmap.draw(vid);
var jpgEncoder:JPGEncoder = new JPGEncoder(100);
var bytes:ByteArray = new ByteArray();
bytes = jpgEncoder.encode(bitmap);
var snapName:String = imgName;
reference.save(bytes, snapName);
}
}
Problem je, ze mi to obrazok neulozi. Ak pouzijem funkciu
complet() priamo /bez casovaca/, cize:
Kód:
function complet(mouseEveten:MouseEvent)
{
...zvysna cast kodu ...
}
tak to funguje bez problemov.. Neviete mi poradit v com by mohol byt problem?? Dakujem.