如何创建一个动作文件AS3
我不明白为什么我在页面上遇到错误?
如何保存我得到的随机文件?
每当我向我显示两个文件时,
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须实现和/或连接到现有的验证码服务器,该服务器将为您的代码提供图像和解决方案。您的
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.