0
votes

I new with flash and I really don't know what is the reason I get this error:

TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at sgmap_fla::MainTimeline/mapOver()

my actionscript:

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});
    }
1
Text fields text cannot be set to null. This could be confirmed by tracing mapItem properties of countryName and zone before setting your textfields: trace(mapItem.countryName); trace(mapItem.zone); From your mapOver event handler, mapItem is seemingly not a zone containing those properties. - Jason Sturges
Hi Jason, it doesn't seems working although I changed from: description.countryName_txt.text = mapItem.countryName; description.zone_txt.text = mapItem.zone; to description.countryName_txt.text = trace(mapItem.countryName); description.zone_txt.text = trace(mapItem.zone); - kokloong

1 Answers

1
votes

Text field text cannot be null.

Specifically this error is caused by setting a text field text property to null. This can be replicated with TextField Classic Text:

Classic Text:

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

This will throw the error your cited:

Error #2007: Parameter text must be non-null.

TLF Text does not have this issue, and may be set to null.

Per your implementation, this occurs within your mapOver(e:MouseEvent) function. Either mapItem.countryName or mapItem.zone are null. It's likely they are both null.

var mapItem:MovieClip = e.target as MovieClip;
description.countryName_txt.text = mapItem.countryName; // null
description.zone_txt.text = mapItem.zone;               // null

Mouse events do not seem to be dispatched from the scope you expect. You have a listener on map_mc:

map_mc.addEventListener(MouseEvent.MOUSE_OVER, mapOver);

It looks like you're expecting this event from any of the following movie clips: northZone, centralZone, eastZone, westZone, and southZone. These symbols have the properties you are looking for; however, map_mc does not.

So, root cause is that your event listener e.target is not the symbol you are expecting.

Verify what symbol e.target is. It's probably map_mc which does not have the properties you are expecting:

map_mc.countryName; // doesn't exist
mac_mc.zone;        // doesn't exist

You're looking for those properties on a child of map_mc:

map_mc.northZone.countryName;
map_mc.northZone.zone;

map_mc.centralZone.countryName;
map_mc.centralZone.zone;

// etc...