【发布时间】:2015-04-02 01:08:36
【问题描述】:
当我尝试这样做时,它不会删除右键。能否请您指出正确的方向以找出问题所在。
private var myArray:Array = [];
private var myButton:Button;
public function addButton():void {
var i:uint = myArray.length;
myButton = new Button();
myButton.label = "New Button"+ String(i);
myButton.id= "myButton" + String(i);
myGroup.addElement(myButton);
myArray.push(myGroup.addElement(myButton));
myButton.addEventListener(MouseEvent.CLICK, removeButton);
}
public function removeButton(event:MouseEvent):void {
//myGroup.removeElement(myArray.splice(2,1)); don´t work
//myGroup.removeElement(myArray.pop()); remove the last one
}
【问题讨论】:
-
那么会发生什么,您希望发生什么,您尝试过什么解决方法?请提供一些细节
-
感谢您的回复,
-
感谢您的回复,我正在尝试删除我单击的按钮,例如:我添加了 3 个按钮 - b1、b2 和 b3。如果我使用 array.pop 并按 b1 ,则 b3 (最后一个)被删除。这不是我想要的,我想删除 b1。希望有意义...
-
help.adobe.com/en_US/AS2LCR/Flash_10.0/… 说
Removes the last element from an array and returns the value of that element.。删除最后一个按钮有什么意外吗?
标签: arrays actionscript-3 apache-flex actionscript