我在使用以下代码时遇到了一些问题:
SideBarText.fontColour.addEventListener(ColorPickerEvent.CHANGE, changeTextColour);
function changeTextColour(e:ColorPickerEvent):void
{
trace (SideBarText.fontColour.selectedColor);
trace (SideBarText.fontColour.hexValue);
var colorInformation:ColorTransform = SideBarText.typeableText.transform.colorTransform;
colorInformation.color = SideBarText.fontColour.selectedColor;
SideBarText.typeableText.transform.colorTransform = colorInformation;
}
fontColour
是ColorPicker的名称,SideBarText
是它所放置的动画片段的变量名称,SideBarText.typeableText
是SideBarText
内的文本字段的名称我试图改变颜色的movieclip。我收到以下错误:
TypeError: Error #1010: A term is undefined and has no properties.
at App_fla::MainTimeline/changeTextColour()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::ColorPicker/onSwatchClick()
任何帮助都将不胜感激。
答案 0 :(得分:0)
null
中的部分对象为undefined
或changeTextColour()
。假设它是SideBarText.typeableText
。在首次亮相时检查它。设置断点并检查它是否定义。