• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Mentor ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

I'm getting the following error:

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

at flash.text::TextField/set text()

at Function/<anonymous>()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()

This is my code:

myButton.addEventListener(MouseEvent.CLICK, onClickNewFB);

function onClickNewFB(e:MouseEvent):String{

var req:URLRequest=new URLRequest(e.target.name+".txt");

var infoLoader:URLLoader=new URLLoader();

var myInfoLoader:String;

infoLoader.load(req);

myInfoLoader=infoLoader.data;

infoLoader.addEventListener(Event.COMPLETE, loadFeedbackText);

//OSD_feedbackText.text=e.target.name;

return myInfoLoader;

function loadFeedbackText(e:Event):void{

//OSD_feedbackText.text=infoLoader.data;

OSD_feedbackText.text=myInfoLoader;

}

trace(myInfoLoader);

}

How do I fix this?  I'm sure I have an incorrect order of operations and I probably shouldn't declare a function within a function but I don't know how else to approach the solution.  Any help is much appreciated.

-markerline

TOPICS
ActionScript

Views

8.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

that means whatever you're trying to load, isn't being found by flash.  use the trace() function to see what you're trying to load


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

Instead of the name of my txt file coming back it's coming back in the output window as "[Object URLRequest]".  That means that the name of my txt file is not being parsed.  How come?  I'm using trace(req);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

Now I'm getting #1067: Implicit coercion of a value of type String to an unrelated type flash.net:URLRequest . . for the following code:

function onClickNewFB(e:MouseEvent):String{

var req:URLRequest=new URLRequest(e.currentTarget.name+".txt");

var infoLoader:URLLoader=new URLLoader();

var myInfoLoader:String;

var myStr:String= new String();

var req2:URLRequest=new URLRequest(myStr);

myStr=e.target.name+".txt";

infoLoader.load("\""+req2+"\"");

trace(myStr);

myInfoLoader=infoLoader.data;

infoLoader.addEventListener(Event.COMPLETE, loadFeedbackText);

//OSD_feedbackText.text=e.target.name;

return myInfoLoader;

function loadFeedbackText(e:Event):void{

//OSD_feedbackText.text=infoLoader.data;

OSD_feedbackText.text=myInfoLoader;

}

trace(myInfoLoader);

}

The error is being thrown on this line:

infoLoader.load("\""+req2+"\"");

I can trace the results of myStr and it gives me the correct filename.  But I cannot seem to pass this filename into my infoLoader.load() method.  What do I do next?

-markerline

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

I fixed the code in the following way:

function onClickNewFB(e:MouseEvent):String{

var req:URLRequest=new URLRequest(e.currentTarget.name+".txt");

var infoLoader:URLLoader=new URLLoader();

var myInfoLoader:String;

var myStr:String= new String();

var req2:URLRequest=new URLRequest('\"'+myStr+'\"');

myStr=e.target.name+".txt";

infoLoader.load(req2);

trace(myStr);

myInfoLoader=infoLoader.data;

infoLoader.addEventListener(Event.COMPLETE, loadFeedbackText);

//OSD_feedbackText.text=e.target.name;

return myInfoLoader;

function loadFeedbackText(e:Event):void{

//OSD_feedbackText.text=infoLoader.data;

OSD_feedbackText.text=myInfoLoader;

}

trace(myInfoLoader);

}

but now I'm getting Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:  <<filename>>

where <<filename>> is an actual location on my computer

at FlashFileName::MainTimeline/onClickNewFB()

. . . I am at a loss.  If I can pass the string to the URL Request and the file exists in my directory, then why am I getting an IO error?

P.S.  I should note that <<filename>> actually appears as ///C|Users/[username]/[directory]/"FILENAME.txt" with the double quotes around the filename.  I also had to put myStr=e.target.name+".txt"; above the previous line to get this far.  If I change the URLRequest to new URLRequest(myStr) then I don't even get an IO Stream error.  I get

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

at flash.text::TextField/set text()

at Function/<anonymous>()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()

????

-markerline

Message was edited by: markerline

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

you shouldn't be using an absolute path to your file.  use a relative path so everything works without security issues and without changing when you upload to a server.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

Yes, kglad.  I'm well aware of the benefits of relative paths.  I was actually simply passing the filename as it stands without directory information but the output console gave me the full path of the filename, which means it's looking in the right place, but it's wrapping the name of the file (not the entire path) with quote marks.  I have since changed my file to not use this scripted method for identifying which file to read and have built the text content into movie clips and accessed the movie clips from frame labels on the timeline.  However I would still like to know how to do it the scripted way for the benefit of me learning how to properly apply this method and for the benefit of others wishing to do the same.

-markerline

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

LATEST

you're doing everything correctly except when constructing your urlrequest.  your argument is incorrect in the urlrequest constructor is problematic.

use the trace() function to see what that is and debug.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines