我是flash的新手,我真的不知道出现此错误的原因是什么:
TypeError:错误#2007:参数文本必须为非null 在flash.text :: TextField / set text()
在sgmap_fla :: MainTimeline / mapOver()
我的动作:
description.countryName_txt.text = "";
description.zone_txt.text = "";
map_mc.buttonMode=true;
map_mc.addEventListener(MouseEvent.MOUSE_OVER, mapOver);
map_mc.addEventListener(MouseEvent.MOUSE_OUT, mapOut);
map_mc.northZone.countryName = "Singapore";
map_mc.northZone.zone = "North Zone";
map_mc.centralZone.countryName = "Singapore";
map_mc.centralZone.zone = "Central Zone";
map_mc.eastZone.countryName = "Singapore";
map_mc.eastZone.zone = "East Zone";
map_mc.westZone.countryName = "Singapore";
map_mc.westZone.zone = "West Zone";
map_mc.southZone.countryName = "Singapore";
map_mc.southZone.zone = "South Zone";
function mapOver(e:MouseEvent):void{
var mapItem:MovieClip = e.target as MovieClip;
description.countryName_txt.text = mapItem.countryName;
description.zone_txt.text = mapItem.zone;
description.gotoAndStop(mapItem.name);
TweenMax.to(mapItem, .5, {tint:0xFF9900});
TweenMax.fromTo(description, .5, {alpha:0, x:50, blurFilter:{blurX:80}}, {alpha:1, x:10, blurFilter:{blurX:0}});
}
function mapOut(e:MouseEvent):void{
var mapItem:MovieClip = e.target as MovieClip;
TweenMax.to(mapItem, .5, {tint:0x990000});
}
答案 0 :(得分:1)
文本字段文本不能为空。
具体而言,此错误是由将文本字段text
属性设置为null
引起的。这可以使用TextField
经典文本:
经典文字:
var tf:TextField = new TextField();
tf.text = null;
这将引发您引用的错误:
错误#2007:参数文本必须为非null。
TLF Text没有此问题,可以设置为null。
根据您的实施,这发生在您的mapOver(e:MouseEvent)
功能中。 mapItem.countryName
或mapItem.zone
均为空。它们可能都是空的。
var mapItem:MovieClip = e.target as MovieClip;
description.countryName_txt.text = mapItem.countryName; // null
description.zone_txt.text = mapItem.zone; // null
似乎没有从您期望的范围调度鼠标事件。你有map_mc
的听众:
map_mc.addEventListener(MouseEvent.MOUSE_OVER, mapOver);
您似乎期望以下任何一个影片剪辑中的此事件:northZone
,centralZone
,eastZone
,westZone
和southZone
。这些符号具有您正在寻找的属性;但是,map_mc没有。
因此,根本原因是您的事件监听器e.target
不是您期望的符号。
验证符号e.target
是什么。它可能是map_mc
,它没有您期望的属性:
map_mc.countryName; // doesn't exist
mac_mc.zone; // doesn't exist
您正在寻找map_mc
的孩子的这些属性:
map_mc.northZone.countryName;
map_mc.northZone.zone;
map_mc.centralZone.countryName;
map_mc.centralZone.zone;
// etc...