这是 AS3 的问题。我有类“addadd”、“Symbol1”(Button1)、“Symbol2”(Button2)。在“添加添加”中,我有 3 个功能。函数“StanishevFadd”创建对象并添加事件侦听器,函数“stanishevFremove”删除事件侦听器,函数“frameDOstanishev”将在添加事件时触发。所以,我显然想从 Symbol1 触发事件并从 Symbol2 停止相同的事件。不幸的是,这种方式不起作用。我完全糊涂了。例如,如果我只想从 Symbol1 添加和删除事件侦听器 - YES 有效,但我无法从 Symbol1 创建事件并从类 addadd 中的 Symbol2 删除相同的事件。请大家帮忙,拜托!
public class addadd
{
var stanishev:stanishev_line = new stanishev_line;
public function addadd()
{
}
public function stanishevFadd()
{
Main.display.addChild(stanishev);
stanishev.gotoAndPlay("start");
stanishev.addEventListener(Event.ENTER_FRAME, frameDOstanishev);
}
public function stanishevFremove()
{
stanishev.removeEventListener(Event.ENTER_FRAME, frameDOstanishev);
}
public function frameDOstanishev(e:Event)
{
trace (stanishev.currentFrame);
}
}
//------------------------------------------
public class Symbol1 extends SimpleButton
{
var call_creator:addadd = new addadd;
public function Symbol1()
{
// constructor code
addEventListener(MouseEvent.MOUSE_OVER, eventResponse);
}
function eventResponse(e:MouseEvent)
{
call_creator.stanishevFadd();
}
}
//------------------------
public class Symbol2 extends SimpleButton
{
var call_creator:addadd = new addadd;
public function Symbol2()
{
// constructor code
addEventListener(MouseEvent.MOUSE_DOWN, eventResponse2);
}
function eventResponse2(e:MouseEvent)
{
call_creator.stanishevFremove();
}
}