?
Solved

How to eliminate TypeError: Error #2007: in following code

Posted on 2009-05-20
6
Medium Priority
?
908 Views
Last Modified: 2013-11-11
I am setting up swf's that have a UILoader to handle external images, a dynamic scrolling textbox to display external test files, and a container MC to handle some other images. Basically, I need the scrolling text box and UILoader to populate on a mouse click, while the container MC works independently.
My code works when I preview it, but I am am getting the following output message, and can't work out how to correct it:
TypeError: Error #2007: Parameter text must be non-null.
      at flash.text::TextField/set text()
      at audiences_fla::MainTimeline/displayText()

-Thanks for any help!
stop();
 
var textLoader:URLLoader = new URLLoader();
 
function loadBodyText(file:String, color:uint) {
	textLoader.load(new URLRequest(file));
}
 
btnGoAudience.addEventListener(MouseEvent.CLICK, displayText);
function displayText(e:Event) {
	loadBodyText("text/whoIntegrated.txt", 0xffffff);
	audienceBodyText.text = (textLoader.data);
	audienceBodyScroll.maxScrollPosition = audienceBodyText.textHeight;
}
 
btnGoAudience.addEventListener(MouseEvent.CLICK, loadInitial);
function loadInitial(e:Event) {
	audienceLoader.source = "images/physicianNetwork.png";
}
 
textLoader.addEventListener(Event.COMPLETE, displayText);
 
 
//load footer image into mc container = mc_audienceFooter
 
var imageLoader:Loader;
 
function imageLoading(e:ProgressEvent):void {
}
 
function imageLoaded(e:Event):void {
	mc_audienceFooter.addChild(imageLoader);
}
 
function loadAudienceFooter(url:String):void {
	imageLoader = new Loader();
	imageLoader.load(new URLRequest(url));
	imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
	loadAudienceFooter("images/audience_footer.png")

Open in new window

0
Comment
Question by:neachtain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24433848

you can't set the text until it has loaded...

audienceBodyText.text = (textLoader.data);


you need to move this into a function that gets called by an event listener...  like the below...


rp / ZA



/// first part of your code...
 
 
function loadBodyText(file:String, color:uint) {
        textLoader.load(new URLRequest(file));
        textLoader.addEventListener( Event.COMPLETE, setTheText);
}
 
function setTheText( evt:Event ):void
{
        audienceBodyText.text = (textLoader.data);
        audienceBodyScroll.maxScrollPosition = textLoader.data.textHeight;  
}
 
btnGoAudience.addEventListener(MouseEvent.CLICK, displayText);
function displayText(e:Event) {
        loadBodyText("text/whoIntegrated.txt", 0xffffff);
}
 
// rest of your code...

Open in new window

0
 

Author Comment

by:neachtain
ID: 24434121
Thanks for the help. Even with that function suggestion, I'm getting the parameter text error message (this time on setTheText() ), additionaly, it won't display the image.

Is there a smarter way of working with the components in gerneral that I am missing?

Thanks!
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 750 total points
ID: 24434683
well, this is a good sign...  we know that it definitely have to do with line 11 in my code above... but just to be sure... you should comment out line 12.


you might need to change this line of code:  audienceBodyText.text = (textLoader.data);

to: audienceBodyText.text = ( evt.target.data);  or possibly   audienceBodyText.text = (evt.currentTarget.data);


and I may have moved some code that I thought was associated with the text issue...  try putting this line of code back into its original spot.


here is what I used...  audienceBodyScroll.maxScrollPosition = textLoader.data.textHeight;  change it back to this and move it back


audienceBodyScroll.maxScrollPosition = audienceBodyText.textHeight;



and I would start using trace(); on things to see what the values of the text that comes in are, and make sure we are passing in actual text data.


rp / ZA

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:neachtain
ID: 24434896
Thanks again! I used currentTarget and got no error output. However, the scrollbar and image won't load now.

I was able to change my original code to and swap out:
audienceBodyText.text = (textLoader.data);
to: audienceBodyText.text = (evt.currentTarget.data);
It works in preview, but I just get a different error message (pertaining to the button function)
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24434954
remember, the more information you give the better... so don't hold back ;)

what was the error, including line number?   you might also do a ctrl + shift + enter  and use the debug player...

it should give you a lot of information that is helpful.


rp / ZA
0
 

Author Comment

by:neachtain
ID: 24435117
It's an output error:
ReferenceError: Error #1069: Property data not found on flash.display.SimpleButton and there is no default value.
      at audiencesBugWorks_fla::MainTimeline/displayText()

Sadly, the de-bugger crashed, but I'll give it another whirl. I haven't used it much (obviously)
Thank you!

 
stop();
 
var textLoader:URLLoader = new URLLoader();
 
function loadBodyText(file:String, color:uint) 
{
	textLoader.load(new URLRequest(file));
}
 
btnGoAudience.addEventListener(MouseEvent.CLICK, displayText);
function displayText(e:Event) 
{
	loadBodyText("text/whoIntegrated.txt", 0xffffff);
	//audienceBodyText.text = (textLoader.data);
	audienceBodyText.text = (e.currentTarget.data);
	audienceBodyScroll.maxScrollPosition = audienceBodyText.textHeight;
}
 
btnGoAudience.addEventListener(MouseEvent.CLICK, loadInitial);
function loadInitial(e:Event) 
{
	audienceLoader.source = "images/physicianNetwork.png";
}
 
textLoader.addEventListener(Event.COMPLETE, displayText);
 
 
//load footer image into mc container = mc_audienceFooter
 
var imageLoader:Loader;
 
function imageLoading(e:ProgressEvent):void 
{
}
 
function imageLoaded(e:Event):void 
{
	mc_audienceFooter.addChild(imageLoader);
}
 
function loadAudienceFooter(url:String):void 
{
	imageLoader = new Loader();
	imageLoader.load(new URLRequest(url));
	imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
	loadAudienceFooter("images/audience_footer.png")
	

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question