AS3 Clicktag Error #1010

好久不见. 提交于 2019-12-11 07:35:00

问题


I got this clicktag but it does not work:

MyClickTagButton.addEventListener(
  MouseEvent.CLICK,
  function():void {
    if (root.loaderInfo.parameters.clickTAG.substr(0,5) == "http:") {
      navigateToURL(
        new URLRequest(root.loaderInfo.parameters.clickTAG), "_blank"
      );
    }
  }
);

When I click it I get this error:

TypeError: Error #1010: A term is undefined and has no properties.
           at Function/< anonymous >()

回答1:


Using anonymous functions as event handlers is a bad practice…

Secondly, do your button has an instance name MyClickTagButton? If not you either has to change its instance name either alter the code to match existing instance name.

MyClickTagButton.addEventListener(MouseEvent.CLICK, onButtonClick);
//this has to match the instance name of the button

function onButtonClick(e:MouseEvent):void 
{
    if (root.loaderInfo.parameters.clickTAG.substr(0,5) == "http:") 
    {
         navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTAG), "_blank");
    }
}

Ah, and the last thing: when you test it in the standalone player the clickTAG parameter is not set, so probably nothing will happen when you click the button.



来源:https://stackoverflow.com/questions/10930620/as3-clicktag-error-1010

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!