当我试图在舞台上创建一个按钮时,我将这四个错误删除了我在输入文本中输入的文本(ti
)。根据我有的脚本和错误,我应该写些什么来创建删除按钮?制作删除按钮以删除输入文本字段中的文本
Attempt to delete the fixed property text. Only dynamically defined properties can be deleted. Access of undefined property delete_btn. Access of possibly undefined property buttonDown through a reference with static type Class. Warning: 3600: Thdeclared property text cannot be deleted. To free associated memory, set its value to null.
delete_btn.addEventListener(MouseEvent.buttonDown, deletetxt);
function deletetxt(event:TextEvent):void {
delete ti.text
}
ti.border = true
ti.addEventListener(TextEvent.TEXT_INPUT, onInput);
function onInput(event:TextEvent):void {
if(ti.text.search('a')!=-1) load_image("http://i54.tinypic.com/anom5d.png", "ottefct");
else if(ti.text.search('b')!=-1) load_image("http://i53.tinypic.com/2dv7dao.png", "rnd");
else if(ti.text.search('c')!=-1) load_image("http://i51.tinypic.com/m8jp7m.png", "ssd");
}
var loaded_images:Dictionary = new Dictionary();
function load_image(url:String, id_name:String)
{
var loader:Loader = new Loader();
loader.name = id_name;
var url_req:URLRequest = new URLRequest(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
loader.load(url_req);
}
function onLoadingComplete(evt:Event):void
{
var img_name:String = evt.currentTarget.loader.name
var spr_box:Sprite = new Sprite();
spr_box.addChild(evt.currentTarget.loader);
spr_box.mouseChildren = false;
spr_box.doubleClickEnabled = true;
spr_box.addEventListener(MouseEvent.MOUSE_DOWN, drag);
spr_box.addEventListener(MouseEvent.MOUSE_UP, drop);
spr_box.addEventListener(MouseEvent.MOUSE_WHEEL, rotate);
spr_box.addEventListener(MouseEvent.DOUBLE_CLICK , unrotate);
spr_box.width = 124;
spr_box.height = 180;
this.addChild(spr_box);
loaded_images[img_name] = spr_box;
}
function drag(evt:MouseEvent):void
{
evt.currentTarget.startDrag()
}
function drop(evt:MouseEvent):void
{
evt.currentTarget.stopDrag()
}
function rotate(evt:MouseEvent):void
{
evt.currentTarget.rotation = 90
}
function unrotate(evt:MouseEvent):void
{
evt.currentTarget.rotation = 0
}
我得到这个错误now.TypeError:错误#1034:类型强制失败:无法将flash.events::[email protected]转换为flash.events.TextEvent。 – starfox55 2010-11-12 04:02:05
是的,对不起,我没有看到TextEvent,它应该是MouseEvent(或者只是Event) – 2010-11-12 11:42:53