AS3 Clicktag错误#1010 [英] AS3 Clicktag Error #1010

查看:70
本文介绍了AS3 Clicktag错误#1010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我获得了这个clicktag,但它不起作用:

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 >()

推荐答案

使用匿名函数作为事件处理程序是一种不好的做法……

Using anonymous functions as event handlers is a bad practice…

第二,您的按钮是否具有实例名称MyClickTagButton?如果不是,那么您要么必须更改其实例名称,要么更改代码以匹配现有的实例名称.

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");
    }
}

是的,最后一件事:当您在独立播放器中对其进行测试时,未设置clickTAG参数,因此,当您单击按钮时,可能什么也不会发生.

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.

这篇关于AS3 Clicktag错误#1010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆