當我試圖在舞臺上創建一個按鈕時,我將這四個錯誤刪除了我在輸入文本中輸入的文本(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