0

以下代码有什么问题,saveButton.visible = false;丢弃按钮.可见 = 假;

package
{
import flash.display.Sprite;
import flash.media.Camera;
import flash.media.Video;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.utils.ByteArray;
import com.adobe.images.JPGEncoder;

public class caml extends Sprite
{
    private var camera:Camera = Camera.getCamera();
    private var video:Video = new Video();
    private var bmd:BitmapData = new BitmapData(320,240);
    private var bmp:Bitmap;
    private var fileReference:FileReference = new FileReference();
    private var byteArray:ByteArray;
    private var jpg:JPGEncoder = new JPGEncoder();

    public function caml()
    {
        saveButton.visible = false;
        discardButton.visible = false;

        saveButton.addEventListener(MouseEvent.MOUSE_UP, saveImage);
        discardButton.addEventListener(MouseEvent.MOUSE_UP, discard);
        capture.addEventListener(MouseEvent.MOUSE_UP, captureImage);

        if (camera != null)
        {
            video.smoothing = true;
            video.attachCamera(camera);
            video.x = 140;
            video.y = 40;
            addChild(video);
        }
        else
        {
            trace("No Camera Detected");
        }
    }
        private function captureImage(e:MouseEvent):void
        {
            bmd.draw(video);
            bmp = new Bitmap(bmd);
            bmp.x = 140;
            bmp.y = 40;
            addChild(bmp);

            capture.visible = false;
            saveButton.visible = true;
            discardButton.visible = true;
        }

        private function saveImage(e:MouseEvent):void
        {
            byteArray = jpg.encode(bmd);
            fileReference.save(byteArray, "Image.jpg");
            removeChild(bmp);
            saveButton.visible = false;
            discardButton.visible = false;
            capture.visible = true;
        }

        private function discard(e:MouseEvent):void
        {
            removeChild(bmp);
            saveButton.visible = false;
            discardButton.visible = false;
            capture.visible = true;
        }


}
}
4

1 回答 1

0

我猜这是一个文档根类,按钮被添加到 flash fla 文件中的阶段。在这种情况下,您需要将按钮添加到您的声明中作为公共成员:

public var saveButton : Button;
public var discardButton : Button;

更新

我自己从不使用 Flash 组件,但您可能会在这里找到有关如何在 Flashbuilder 中使用 Flash 组件的答案: http ://www.moock.org/blog/archives/000253.html http://www.ruttencutter.com/ ?p=20

于 2010-12-23T06:48:57.937 回答