• 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 url must be non-null -- HELP!

New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Hey everyone. I (along with everyone else who posts a question here) am fairly new to AS3. So I am going crazy trying to figure out what is causing this error. I have a 'jukebox' player that loads songs accordingly when the button is clicked. BUT this is my error:

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

          at flash.media::Sound/_load()

          at flash.media::Sound/load()

          at lesson09_V2_S5_fla::MainTimeline/frame1()

And this is my code:

import fl.events.SliderEvent;

//create instances of the three sound related classes that will be used for this project

var snd:Sound;

var channel:SoundChannel;

var trans:SoundTransform;

//create variables to store values for the current song and it's volume and pan settings.

var currSong:String;

var currVol:Number = .5;

var currPan:Number = 0;

// Array of all the songs in the current playlist.

var songList:Array=new Array("Nothing On You.mp3","Grenade.mp3","Ride.mp3","Pretty Girl Rock.mp3","Tick Tock.mp3","Dynamite.mp3");

// don't need to see the volume and pan controls until a song is playing

panSlide.visible=false;

volSlide.visible=false;

//Listeners for the onstage song buttons

song1.addEventListener(MouseEvent.CLICK, chooseSong);

song2.addEventListener(MouseEvent.CLICK, chooseSong);

song3.addEventListener(MouseEvent.CLICK, chooseSong);

song4.addEventListener(MouseEvent.CLICK, chooseSong);

song5.addEventListener(MouseEvent.CLICK, chooseSong);

song6.addEventListener(MouseEvent.CLICK, chooseSong);

//listeners for the volume and pan sliders

panSlide.addEventListener(SliderEvent.CHANGE, panChange);

volSlide.addEventListener(SliderEvent.CHANGE, volumeChange);

//sets the text field of all of the song buttons to display the names of the songs in the songList array

for (var i = 0; i < songList.length; i++) {

          var str:String = songList as String;

          str = str.replace(".mp3","");

          var clip = this["song" + (i + 1)].title;

          clip.text = str;

}

//switch statement to set the current song based on which song button was clicked.

function chooseSong(e:MouseEvent):void {

          switch (e.currentTarget.name) {

                    case "song1":

                              currSong = "../MP3s/"+songList[0] as String;

                              break;

                    case "song2":

                              currSong = "../MP3s/"+songList[1] as String;

                              break;

                    case "song3":

                              currSong = "../MP3s/"+songList[2] as String;

                              break;

                    case "song4":

                              currSong = "../MP3s/"+songList[3] as String;

                              break;

                    case "song5":

                              currSong = "../MP3s/"+songList[4] as String;

                              break;

                    case "song6":

                              currSong = "../MP3s/"+songList[5] as String;

                              break;

          }

}

          if (snd != null) {

                    channel.stop();

          }

          snd = new Sound();

          snd.load(new URLRequest(currSong));

          snd.addEventListener(IOErrorEvent.IO_ERROR, onError);

function onError(e:IOErrorEvent):void {

    // Do nothing

}

          channel = new SoundChannel  ;

          trans = new SoundTransform(currVol,currPan);

          channel = snd.play();

          channel.soundTransform = trans;

          panSlide.visible = true;

          volSlide.visible = true;

          //currVolume and pan values are used here for display in the text fields next to sliders

          volLabel.text = "Current Volume " + int(currVol * 100);

          panLabel.text = "Current Pan " + int(currPan * 100);

          //listens for arrival of ID3 tags

          snd.addEventListener(Event.ID3, id3Handler);

//triggered when id3 tags are available

//sets info text field to display current song information from id3 tags.

function id3Handler(event:Event):void {

          var id3:ID3Info = snd.id3;

          if (id3.songName != null) {

                    songTitle.text = id3.songName + "\n";

                    info.text="Artist: \n"+id3.artist+"\n \n";

                    info.appendText("Album: \n" + id3.album);

                    info.appendText("\n\n" + "Available at: \n" + "passionrecords \n.com");

          }

}

var format:TextFormat = new TextFormat();

format.font = "Arial Black";

format.color = 0xFFFF00;

format.size = 14;

format.url = "http://www.passionrecords.com/";

info.defaultTextFormat = format;

// uses volume slider value to control volume

function volumeChange(e:SliderEvent):void {

          currVol = e.target.value;

          volLabel.text = "Current Volume: " + int(currVol*100);

          trans.volume = currVol;

          channel.soundTransform = trans;

}

// uses pan slider value to control pan

function panChange(e:SliderEvent):void {

          currPan = e.target.value;

          panLabel.text = "Current Pan " + int(currPan*100);

          trans.pan = e.target.value;

          channel.soundTransform = trans;

}

Any help would be greatly appreciated! Thanks!

TOPICS
ActionScript

Views

2.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

correct answers 1 Correct answer

LEGEND , Dec 03, 2013 Dec 03, 2013

That looks like another case of code not being placed where it needs to be.

If that code is not in a function, then it is executing immediately when the program starts.  At that point snd is not defined, only declared.  You do not create the instance until the line... snd = new Sound();   which I believe you have now moved inside a function.

You probably need to go thru all the code to see what pieces you still have floating around that need homes inside functions.

Votes

Translate

Translate
LEGEND ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Thew following section of your code appears to be stuck in the middle of nowhere such that chances are the currSong value is null at that point in time.  My guess is that it belongs inside the function that precedes it.

          if (snd != null) {

                    channel.stop();

          }

          snd = new Sound();

          snd.load(new URLRequest(currSong));

          snd.addEventListener(IOErrorEvent.IO_ERROR, onError);

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Hmmm. I included it in the function and now i'm getting:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at lesson09_V2_S5_fla::MainTimeline/frame1()

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

And I understand this error is basically saying that I am trying to access omething I have not named, but I cannot figure out where in the code this refers to....

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
LEGEND ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Thanks, that actually a handy trick to know. When I debug, it refers me to this line:

channel = snd.play();

I don't get what the problem is though. The variable is definied up top. Ugh, now I'm more confused LOL

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
LEGEND ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

That looks like another case of code not being placed where it needs to be.

If that code is not in a function, then it is executing immediately when the program starts.  At that point snd is not defined, only declared.  You do not create the instance until the line... snd = new Sound();   which I believe you have now moved inside a function.

You probably need to go thru all the code to see what pieces you still have floating around that need homes inside functions.

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Thanks for helping me out! that was the case... but, as usual, another error came when I fixed that one

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.

          at lesson09_V2_S5_fla::MainTimeline/chooseSong()[lesson09_V2_S5_fla.MainTimeline::frame1:73

which is line:

snd = new Sound();

Suggestions on this one? Thanks for your time again!

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

Now I am not sure if I made it better or worse. I added some code and now I get no errors, but the songs do not play when clicked. Nothing happens. With no errors. The bold code is what I added

import fl.events.SliderEvent;

//create instances of the three sound related classes that will be used for this project

var snd:Sound;

var channel:SoundChannel;

var trans:SoundTransform;

//create variables to store values for the current song and it's volume and pan settings.

var currSong:String;

var currVol:Number = .5;

var currPan:Number = 0;

// Array of all the songs in the current playlist.

var songList:Array=new Array("Nothing On You.mp3","Grenade.mp3","Ride.mp3","Pretty Girl Rock.mp3","Tick Tock.mp3","Dynamite.mp3");

// don't need to see the volume and pan controls until a song is playing

panSlide.visible=false;

volSlide.visible=false;

//Listeners for the onstage song buttons

song1.addEventListener(MouseEvent.CLICK, chooseSong);

song2.addEventListener(MouseEvent.CLICK, chooseSong);

song3.addEventListener(MouseEvent.CLICK, chooseSong);

song4.addEventListener(MouseEvent.CLICK, chooseSong);

song5.addEventListener(MouseEvent.CLICK, chooseSong);

song6.addEventListener(MouseEvent.CLICK, chooseSong);

//listeners for the volume and pan sliders

panSlide.addEventListener(SliderEvent.CHANGE, panChange);

volSlide.addEventListener(SliderEvent.CHANGE, volumeChange);

//sets the text field of all of the song buttons to display the names of the songs in the songList array

for (var i = 0; i < songList.length; i++) {

          var str:String = songList as String;

          str = str.replace(".mp3","");

          var clip = this["song" + (i + 1)].title;

          clip.text = str;

}

//switch statement to set the current song based on which song button was clicked.

function chooseSong(e:MouseEvent):void {

          switch (e.currentTarget.name) {

                    case "song1":

                              currSong = "../MP3s/"+songList[0] as String;

                              break;

                    case "song2":

                              currSong = "../MP3s/"+songList[1] as String;

                              break;

                    case "song3":

                              currSong = "../MP3s/"+songList[2] as String;

                              break;

                    case "song4":

                              currSong = "../MP3s/"+songList[3] as String;

                              break;

                    case "song5":

                              currSong = "../MP3s/"+songList[4] as String;

                              break;

                    case "song6":

                              currSong = "../MP3s/"+songList[5] as String;

                              break;

          }

          if (snd != null)

          {

                    channel.stop();

          }

          snd = new Sound();

          snd.load(new URLRequest(currSong));

          snd.addEventListener(IOErrorEvent.IO_ERROR, onError);

function onError(e:IOErrorEvent):void {

// Do nothing

}

          channel = new SoundChannel    ;

          trans = new SoundTransform(currVol,currPan);

          channel = snd.play();

          channel.soundTransform = trans;

          panSlide.visible = true;

          volSlide.visible = true;

          //currVolume and pan values are used here for display in the text fields next to sliders

          volLabel.text = "Current Volume " + int(currVol * 100);

          panLabel.text = "Current Pan " + int(currPan * 100);

          //listens for arrival of ID3 tags

          snd.addEventListener(Event.ID3, id3Handler);

          }

//triggered when id3 tags are available

//sets info text field to display current song information from id3 tags.

function id3Handler(event:Event):void {

          var id3:ID3Info = snd.id3;

          if (id3.songName != null) {

                    songTitle.text = id3.songName + "\n";

                    info.text="Artist: \n"+id3.artist+"\n \n";

                    info.appendText("Album: \n" + id3.album);

                    info.appendText("\n\n" + "Available at: \n" + "passionrecords \n.com");

          }

}

var format:TextFormat = new TextFormat();

format.font = "Arial Black";

format.color = 0xFFFF00;

format.size = 14;

format.url = "http://www.passionrecords.com/";

info.defaultTextFormat = format;

// uses volume slider value to control volume

function volumeChange(e:SliderEvent):void {

          currVol = e.target.value;

          volLabel.text = "Current Volume: " + int(currVol*100);

          trans.volume = currVol;

          channel.soundTransform = trans;

}

// uses pan slider value to control pan

function panChange(e:SliderEvent):void {

          currPan = e.target.value;

          panLabel.text = "Current Pan " + int(currPan*100);

          trans.pan = e.target.value;

          channel.soundTransform = trans;

}

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
LEGEND ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

That last error you had looks more like a file opening/reading error which is likely a mistargeting of a file (not finding it where you tell it to look).  I see some code that should have been moved elsewhere still, so I have to doubt if I am looking at the latest version of the code.

The new code you added is likely to hide that error being reported since you have it calling a function that does nothing.  That is probably why nothing happens now.

Try putting a trace in that function instead to see if it is executing that function and to see what file it is failing to find.

function onError(e:IOErrorEvent):void {

     trace("Can't load: " + currSong)

}

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

I feel so dumb sometimes LOL ....of course it would do nothing... I told it too. Thanks for that! Now the trace function shows that it

Can't load: ../MP3s/Nothing On You.mp3

Can't load: ../MP3s/Grenade.mp3

The paths are correct....the songs are in the parent folder of the current Flash file.

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
LEGEND ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

The best I can do at this point is disagree and tell you that you are probably missing the target.  This can get compounded if you start weaving an html file into the loop as well.

To eliminate the targeting issue for the moment, move/copy one of the mp3 files into the same folder as the Flash file and change the url for it accordingly.

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
New Here ,
Dec 03, 2013 Dec 03, 2013

Copy link to clipboard

Copied

WowGot it. The paths were correct....but my titles were not the same .... Dynamite.mp3 in my code was not named Dynamite.mps in the MP3 folder Stupid  small mistakes. Now it works perfect.

Thank you, Ned, for putting up with my questions and helping!!

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
LEGEND ,
Dec 04, 2013 Dec 04, 2013

Copy link to clipboard

Copied

LATEST

You're welcome

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