问题
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