07.31.07
Flash/Flex AS3 Error #2007
Error #2007: Parameter text must be non-null.It is the error of the year Error 2007. This error is very ambiguous but is not hard to understand once you realize what it means.
This error means that you are trying to assign an object some text but you forget to target the text and instead you target the text field. In the bad example below '.text' is forgotten. It is included in the Good Code
Bad Code:
for (var i:int = 0; i<15; i++) {
array[i] = myText_txt;
}
Good Code:
for (var i:int = 0; i<15; i++) {
array[i] = myText_txt.text;
}
And that is how you solve ActionScript Error #2007: Parameter text must be non-null.
As always Happy Flashing
Paul said,
October 21, 2007 at 1:23 am
I also got this error after trying to use a bad function argument:
Bad: myLoader.addEventListener(Event.PROGRESS,xmlLoading);
Good: myLoader.addEventListener(ProgressEvent.PROGRESS,xmlLoading);
Really this is just another text mistake, but hidden beneath a bad event type constant.
Ryan Daly said,
February 4, 2008 at 12:26 am
I received this error because of a CLICK event calling a function that takes a String… This may be common sense for most, but it had me thinking for quite awhile! A MouseEvent listener must call a MouseEvent function… In this case anyway…
BAD:
example_btn.addEventListener(MouseEvent.CLICK, exampleFunction);
function exampleFunction( feedURL:String )
{
do stuff
}
GOOD:
example_btn.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler (MouseEvent:Event):void
{
exampleFunction(feedURLvar);
}
function exampleFunction( feedURL:String )
{
do stuff
}
Hope this helps someone… and thanks Curtis, I find myself here quite often!
Curtis J. Morley said,
February 4, 2008 at 10:26 pm
Ryan,
Thanks for pointing this out. I am glad my posts help. That is what I created this blog for.
Curtis J. Morley
Chris said,
February 5, 2008 at 12:55 pm
This error happened for me when I was giving a text field data not specifically turned into a String.
I used ‘ String(variableThatIsNotAString) ‘, works fine now
Curtis J. Morley said,
February 5, 2008 at 11:22 pm
Chris,
By casting the variable as a string it will eliminate AS3 error #2007. Casting a variable makes whatever dataType you started with into a string. Thanks for the post.
Curtis J. Morley