如何创建一个动作文件AS3

发布于 2025-01-27 15:39:29 字数 3065 浏览 2 评论 0原文

我不明白为什么我在页面上遇到错误?

如何保存我得到的随机文件?

每当我向我显示两个文件时,

public class Captcha extends MovieClip
{
    public var captchaClip:MovieClip;
    public var reloadBut:SimpleButton;
    public var captchaText:TextField;
    public var captchaBG:MovieClip;
    private var captchaLoader:Loader = null;
    private var url:String = null;
    private var imageWidth:int;
    private var imageHeight:int;
    private var reloadButton:Object;

    public function Captcha()
    {
        this.captchaText.defaultTextFormat = TextFormats.format(14, true, TextFormatAlign.CENTER);
        this.captchaText.multiline = false;
        this.captchaText.restrict = "1234567890";
        this.reloadButton = getChildByName("reloadBut");
        if (this.reloadButton)
        {
            this.reloadButton.addEventListener(MouseEvent.CLICK, this.reloadButClick, 0, false, true);
        }
        return;
    }// end function

    private function reloadButClick(event:MouseEvent) : void
    {
        this.reset();
        event.stopImmediatePropagation();
        return;
    }// end function

    public function getUserInput() : String
    {
        return this.captchaText.text;
    }// end function

    public function setUrl(param1:String, param2:int = 3, param3:int = 72, param4:int = 25)
    {
        this.url = param1;
        this.imageHeight = param4;
        this.imageWidth = param3;
        this.captchaText.maxChars = param2;
        return;
    }// end function

    public function reset()
    {
        this.captchaText.text = "";
        this.loadCaptcha();
        return;
    }// end function

    private function loadCaptcha()
    {
        this.captchaText.text = "";
        this.captchaLoader = new Loader();
        this.captchaLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.captchaLoaded);
        this.captchaLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        var _loc_1:* = new LoaderContext();
        _loc_1.checkPolicyFile = true;
        var _loc_2:* = new URLRequest(this.url + "?random=" + Math.random());
        this.captchaLoader.load(_loc_2, _loc_1);
        return;
    }// end function

    private function captchaLoadError(event:IOErrorEvent) : void
    {
        event.target.removeEventListener(Event.COMPLETE, this.captchaLoaded);
        event.target.removeEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        return;
    }// end function

    private function captchaLoaded(event:Event) : void
    {
        event.target.removeEventListener(Event.COMPLETE, this.captchaLoaded);
        event.target.removeEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        var _loc_2:* = event.target.content;
        _loc_2.height = this.imageHeight;
        _loc_2.width = this.imageWidth;
        this.captchaClip.addChild(_loc_2);
        return;
    }// end function

}

我都需要构建这些文件吗?如果是这样,这些操作文件中应该有什么?

在这里,您可以看到为我创建的错误:

感谢您的理解(我对语言非常新鲜,因此真正需要帮助)。

I can not understand why I get an error on the page?

How do I save the random files I get?

Every time it shows me an error regarding both files

public class Captcha extends MovieClip
{
    public var captchaClip:MovieClip;
    public var reloadBut:SimpleButton;
    public var captchaText:TextField;
    public var captchaBG:MovieClip;
    private var captchaLoader:Loader = null;
    private var url:String = null;
    private var imageWidth:int;
    private var imageHeight:int;
    private var reloadButton:Object;

    public function Captcha()
    {
        this.captchaText.defaultTextFormat = TextFormats.format(14, true, TextFormatAlign.CENTER);
        this.captchaText.multiline = false;
        this.captchaText.restrict = "1234567890";
        this.reloadButton = getChildByName("reloadBut");
        if (this.reloadButton)
        {
            this.reloadButton.addEventListener(MouseEvent.CLICK, this.reloadButClick, 0, false, true);
        }
        return;
    }// end function

    private function reloadButClick(event:MouseEvent) : void
    {
        this.reset();
        event.stopImmediatePropagation();
        return;
    }// end function

    public function getUserInput() : String
    {
        return this.captchaText.text;
    }// end function

    public function setUrl(param1:String, param2:int = 3, param3:int = 72, param4:int = 25)
    {
        this.url = param1;
        this.imageHeight = param4;
        this.imageWidth = param3;
        this.captchaText.maxChars = param2;
        return;
    }// end function

    public function reset()
    {
        this.captchaText.text = "";
        this.loadCaptcha();
        return;
    }// end function

    private function loadCaptcha()
    {
        this.captchaText.text = "";
        this.captchaLoader = new Loader();
        this.captchaLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.captchaLoaded);
        this.captchaLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        var _loc_1:* = new LoaderContext();
        _loc_1.checkPolicyFile = true;
        var _loc_2:* = new URLRequest(this.url + "?random=" + Math.random());
        this.captchaLoader.load(_loc_2, _loc_1);
        return;
    }// end function

    private function captchaLoadError(event:IOErrorEvent) : void
    {
        event.target.removeEventListener(Event.COMPLETE, this.captchaLoaded);
        event.target.removeEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        return;
    }// end function

    private function captchaLoaded(event:Event) : void
    {
        event.target.removeEventListener(Event.COMPLETE, this.captchaLoaded);
        event.target.removeEventListener(IOErrorEvent.IO_ERROR, this.captchaLoadError);
        var _loc_2:* = event.target.content;
        _loc_2.height = this.imageHeight;
        _loc_2.width = this.imageWidth;
        this.captchaClip.addChild(_loc_2);
        return;
    }// end function

}

Do I need to build these files? If so what should be inside these ACTION files?

Here you can see the errors that are created for me:

Thanks for understanding (I'm pretty new to the language so help really got needed).

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

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

发布评论

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

评论(1

我不会写诗 2025-02-03 15:39:29

您必须实现和/或连接到现有的验证码服务器,该服务器将为您的代码提供图像和解决方案。您的localhost:8080 Web服务器显然不知道如何在验证码请求上做出反应,从而返回404。

You have to implement and/or connect to an existing CAPTCHA server that would provide your code with images and solutions. Your localhost:8080 web server apparently does not know how to react on your CAPTCHA requests thus returns a 404.

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