AS项目中保存按钮错误

发布于 2024-10-08 21:06:56 字数 2263 浏览 2 评论 0原文

下面的代码有什么问题,有错误 保存按钮.visible = false; 丢弃按钮.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;
        }


}
}

Whats wrong with the following code,There is an error at
saveButton.visible = false;
discardButton.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;
        }


}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘世孤行 2024-10-15 21:06:56

我猜这是一个文档根类,按钮被添加到 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

I guess this is a document root class and the buttons is added to stage in the flash fla file. In that case you need to add the buttons to your declaration as public members:

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

UPDATE

I never use the flash components myself but you might find an answer here on how to use Flash components in Flashbuilder:
http://www.moock.org/blog/archives/000253.html
http://www.ruttencutter.com/?p=20

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文