如何声明Event Listener为公共状态,以便它可用于所有功能?as3声明一个eventListener - 变量范围
// Coded needed below to declare Event
function addEventL()
{
/// Declares it in a function
myMovie.addEventListener(MouseEvent.CLICK, menuIn);
}
function removeEventL()
{
/// This does not work because it was first called in a function.
/// So it can not find the event Listener to remove.
myMovie.removeEventListener(MouseEvent.CLICK, menuIn);
}
什么是三个功能(addEventL,removeEventL,menuIn)之间的关系。他们都在相同的范围内? – BadFeelingAboutThis
你的代码如图所示(全部在相同的范围内)将工作。 – BadFeelingAboutThis
事件侦听器不受范围的影响。唯一可能发生的范围问题是处理程序不在范围内。 –