0

我是 Flash 新手,我真的不知道我收到此错误的原因是什么:

TypeError:错误 #2007:参数文本必须为非空。
在 flash.text::TextField/设置 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});
    }
4

1 回答 1

1

文本字段文本不能为空。

具体来说,此错误是由将文本字段text属性设置为null. 这可以用TextField经典文本复制:

经典文字:

var tf:TextField = new TextField();
tf.text = null;

这将引发您引用的错误:

错误 #2007:参数文本必须为非空。

TLF Text 没有这个问题,可以设置为 null。

根据您的实现,这发生在您的mapOver(e:MouseEvent)函数中。要么 要么mapItem.countryNamemapItem.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);

您似乎希望从以下任何影片剪辑中发生此事件:northZonecentralZoneeastZonewestZonesouthZone。这些符号具有您正在寻找的属性;但是, 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...
于 2012-07-10T05:00:08.790 回答