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
I have this error, [lease help me…
O’m trying to target a data and display it on a textfiel
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at bargraph_fla::myGraphApp_1/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I am new to AS period, but I am following some training videos to create a portfolio site where the images and text are loaded by xml.
I have followed the instructions to the letter; however I am getting the #2007 Parameter text must be not-null error. I have pasted my code below:
var titleArray:Array = new Array();
var descriptionArray:Array = new Array();
var largeImageArray:Array = new Array();
var thumbnailImageArray:Array = new Array();
var imageNum:Number=0;
var totalImages:Number;
//XML
//load in XML
var XMLURLLoader:URLLoader = new URLLoader();
XMLURLLoader.load(new URLRequest(“assets/portfolio/portfolio.xml”));
XMLURLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(event:Event):void {
var theXMLData:XML=new XML(XMLURLLoader.data);
totalImages=theXMLData.title.length();
for (var i:Number = 0; i < totalImages; i++) {
titleArray.push(theXMLData.title[i]);
descriptionArray.push(theXMLData.description[i]);
largeImageArray.push(theXMLData.largeImage[i]);
thumbnailImageArray.push(theXMLData.thumbImage[i]);
}
loadThumbnail();
}
myScrollPane.source=allThumbnails;
//LOAD THE THUMBNAILS
function loadThumbnail():void {
trace(imageNum);
var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(thumbnailImageArray[imageNum]));
thumbLoader.x = 90*imageNum;
//stores the appropriate info for thumbnail
var thisLargeImage:String = largeImageArray[imageNum];
var thisTitle:String = titleArray[imageNum];
var thisDescription:String = descriptionArray[imageNum];
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
function thumbLoaded(event:Event):void {
//add the thumbnails to the allThumbnails instance
allThumbnails.addChild(thumbLoader);
allThumbnails.buttonMode = true;
myScrollPane.update();
thumbLoader.addEventListener(MouseEvent.CLICK, loadMainImage1);
function loadMainImage1(event:MouseEvent):void {
largeUILoader.source=thisLargeImage;
selectedTitle.text=thisTitle;
selectedDesc.text=thisDescription;
}
}
//add to imageNum (1);
imageNum++;
if (imageNum<totalImages) {
loadThumbnail();
}
}
I know my error has something to do with this part of the code:
//stores the appropriate info for thumbnail
var thisLargeImage:String = largeImageArray[imageNum];
var thisTitle:String = titleArray[imageNum];
var thisDescription:String = descriptionArray[imageNum];
but I can’t figure out what’s wrong. When I test my movie, everything functions correctly except when I click on a different thumbnail, the proper description does not load. My xml file is set up correctly. Here is a bit of that code:
Spark Your Imagination Ad
<![CDATA[These black & white ads were designed to run in the trade publication The Green Sheet in the Merchant Acquiring Industry]]>
assets/portfolio/lg/1.jpg
assets/portfolio/thumbs/1.jpg
Corporate Business Card – iMax Bancard
<![CDATA[This full color double-sided business card is the current standard card being used by employees and agents of iMax Bancard]]>
assets/portfolio/lg/2.jpg
assets/portfolio/thumbs/2.jpg
The only thing different with my xml code is that in the tutorial I am following, the tags are on the outside of the CDATA tags (which I have seen examples of both)… but when I put the code that way, it causes breaks in my code at the first special character I use.
Any help is appreciated. Thanks, Jen
plz help me
rect_mc.buttonMode = true;
var holder:MovieClip = new MovieClip();
var myArr:Array = [“rectangle tool”,”pencilTool”,”selecttool”];
function trys() {
for (var i =0; i<=3; i++) {
}
}
rect_mc.addEventListener(MouseEvent.MOUSE_OVER, showtip);
function showtip(evt:MouseEvent):void {
var myTip:tip = new tip();
holder = myTip;
addChild(myTip);
holder.x = stage.mouseX + 15;
holder.y = stage.mouseY;
holder.toolTip.text = myArr[evt.target.val];
}
rect_mc.addEventListener(MouseEvent.MOUSE_OUT, shown);
function shown(evt:MouseEvent):void{
removeChild(holder);
}
trys();
iam gettin the error Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
Hey, you guys with a hittest problem: this happened to me because the object was removed while the loop with the test in it was still running. I solved this by adding a modifier so the collision detection loop would only run if the object being tested actually existed (here, the object being tested is bullets and the collision-detecting instance is e.target):
//test if any instance of bullets exists, I have them in an array. Prevents next code-block from running if bullets[i] doesn’t exist.
if (bullets[i]){
//test if bullets and enemy are colliding. Before, this was running even after bullets[i] was removed, causing the error
if (e.target.hitTestObject(bullets[i])){
//This is the pixel-perfect collision detection
}
}
I’m pretty new to ActionScript, so I have no idea if this is the most efficient way, but it works great! My system is built so that pixel-perfect collision detection is only run when hitboxes collide, for optimization.
I am getting the same error, any help would be appreciated:
TypeError: Error #2007: Parameter url must be non-null.
at flash.display::Loader/_load()
at flash.display::Loader/load()
at net.flightmaps.ui.controls.preload::Preloader/addedToStageHandler()[/Users/innovatauser/Documents/Flex Builder 3/genmap/trunk/src/net/flightmaps/ui/controls/preload/Preloader.as:261]
at flash.display::DisplayObjectContainer/addChild()
at mx.preloaders::Preloader/initialize()[C:\dev\flex_201_gmc\sdk\frameworks\mx\preloaders\Preloader.as:182]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[C:\dev\flex_201_gmc\sdk\frameworks\mx\managers\SystemManager.as:1435]
at mx.managers::SystemManager/initHandler()[C:\dev\flex_201_gmc\sdk\frameworks\mx\managers\SystemManager.as:2124]
Line 182:
protected function createChildren():void
{
if (!_splashScreen)
{
_splashScreen = new Loader();
}
addChild(_splashScreen);
_progressBar = addChild(new DownloadProgressBar()) as DownloadProgressBar;
_messageField = addChild(new TextField()) as TextField;
_messageField.embedFonts = false;
_messageField.multiline = false;
_messageField.selectable = false;
_messageField.defaultTextFormat = labelFormat;
_messageField.text = “Starting up, please wait…”;
}
Line 261:
private function addedToStageHandler(evt:Event):void
{
evt.target.removeEventListener(evt.type, arguments.callee);
if (_splashScreen && !_hasLoadedSplashScreen)
{
var parameters:Object = stage.loaderInfo.parameters;
_splashScreen.load(new URLRequest(parameters.splashScreenURL));
_hasLoadedSplashScreen = true;
}
}
im getting the same error. any help is appreciated.
see my code below:
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
var externaltextload:URLLoader = new URLLoader( );
externaltextload.load(new URLRequest(“terms.html”));
text_mc.text_mc.termsText.text = externaltextload.data;
same as Nigelaj…..
I get the #2007 error with a histtest. It says:
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at ToxicWalls2beta_fla::MainTimeline/event4()
Can anyone help me please? First time I’m coding in AS3 🙂
//Nigelaj
Another great way of generating this error message is by trying to add a component with Actionscript but forgetting to add the component to the library. Grrrr…
okay, so it was because my XML file didn’t have enough items in it.
i had a for (var i) loop requesting the data of 5 items.
and the variables (i + addition) we summed to retrieve the true id of the XML item.
but i had only 10 items so the error appeared when i needed to retrieve the data of XML item 11 (i=5 + addition=6 // item 11)
i’m error free as long as the variable integer remains 5 or beneath.
does anyone have any ideas on a possible cause?
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
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 🙂
Ryan,
Thanks for pointing this out. I am glad my posts help. That is what I created this blog for.
Curtis J. Morley
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!
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.