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

TypeError: Error #2007: Parameter url must be non-null. at flash.media::Sound/_load()

Participant ,
Apr 19, 2018 Apr 19, 2018

Im trying to make a MP3 player that gets the file from a XML hosted on my webpage. The FLA file has 3 keyframes with code.

I have a list from component panel called list, and a dynamic text field called status_txt

I can excecute the program, but when I click a channel in the list I get this error:

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

at flash.media::Sound/_load()

at flash.media::Sound/load()

at PlayingSoundFromXMLfileWeb_fla::MainTimeline/frame3()[PlayingSoundFromXMLfileWeb_fla.MainTimeline::frame3:12]

Doesnt matter what channel I excecute.

Keyframe1:

stop();

import fl.controls.List;

import flash.net.URLRequest;

import flash.net.URLLoader;

import flash.events.Event;

list.width=stage.stageWidth;

list.height=600

list.x=(stage.stageWidth - list.width)/2;

list.y=0;

list.rowHeight=50;

var myFormat:TextFormat = new TextFormat();

myFormat.color="0xFFFFFF";

list.setRendererStyle("textFormat",myFormat);

var trackToPlay:String;

var pausePosition:int=0;

var songURL:URLRequest;

var i:uint;

var myXML:XML =new XML();

var XML_URL:String ="http://blogglista.no/something.xml";

var myXMLURL:URLRequest = new URLRequest(XML_URL);

var myLoader:URLLoader = new URLLoader(myXMLURL);

myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void{

myXML = XML(myLoader.data);

var firstSong:String = myXML..Song.songTitle[0];

var firstArtist:String = myXML..Song.songArtist[0];

var firstURL:String= myXML..Song.songURL[0];

songURL = new URLRequest(firstURL);

status_txt.text ="1. " +firstSong + "- "+firstArtist;

for each (var Song:XML in myXML..Song){

i++;

var songTitle:String = Song.songTitle.toString();

var songsongURL:String = Song.songURL.toString();

var songArtist:String=Song.songArtist.toString();

//songURL = Song.songURL.toString();

list.addItem({label: i+"."+songTitle+"-"+songArtist, songString: songsongURL,Artist: songArtist, songNum: i});

}

var myArray = new Array(0,0);

list.selectedIndices= myArray;

gotoAndStop(3);

}

Then the second keyframe has this code:

import flash.net.URLRequest;

songURL = new URLRequest(trackToPlay);

And finally the third keyframe has this code:

import flash.media.Sound;

import flash.media.SoundChannel;

import flash.media.SoundLoaderContext;

import flash.events.Event;

stop();

var snd:Sound=new Sound();

var channel:SoundChannel;

var context:SoundLoaderContext= new SoundLoaderContext(5000, true);

snd.load(songURL, context);

channel = snd.play(pausePosition);

list.addEventListener(Event.CHANGE, itemClick);

function itemClick(event:Event):void{

channel.stop();

status_txt.text = "Now Playing: " + event.target.selectedItem.label + ".mp3";

trackToPlay = event.target.selectedItem.songURL;

//trace(event.target.selectedItem);

trace(event.target.selectedItem.songString);

gotoAndPlay(2);

}

My mission is to import quite a lot of stream URLs.

TOPICS
ActionScript
1.7K
Translate
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

Community Expert , Apr 21, 2018 Apr 21, 2018

in your 3rd frame, what's this show:

  1. function itemClick(event:Event):void{ 
  2.  
  3. channel.stop(); 
  4. status_txt.text = "Now Playing: " + event.target.selectedItem.label + ".mp3"; 
  5. trackToPlay = event.target.selectedItem.songURL; 
  6. trace('ttp:',trackToPlay);
  7. gotoAndPlay(2); 
  8. }

when that shows null or an empty string, fix your parsing in xmlLoaded in your first frame, or fix your xml to work with your parsing.

Translate
Community Expert ,
Apr 19, 2018 Apr 19, 2018

trackToPlay is needed (to be defined and non-null) in frame 2 and isn't defined until after it's used in snd.load().  fix that.

Translate
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
Participant ,
Apr 19, 2018 Apr 19, 2018

I changed

var trackToPlay:String;

to

var trackToPlay:String="http://cast.loungefm.com.ua/terrace128?1372841071202.mp3";

Still getting the same issues unfortunately

Translate
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 ,
Apr 19, 2018 Apr 19, 2018

i assume that's in frame 1.

if so, does frame 2 play before frame 3?  (it doesn't look like it.)

Translate
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
Participant ,
Apr 19, 2018 Apr 19, 2018

Yeah, the changes made are in frame 1,

frame 1 plays first. then frame 3 , then frame 2 if the list is clickd and right back to frame 3

Translate
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 ,
Apr 19, 2018 Apr 19, 2018

if frame 2 doesn't play, then songURL is still null and causing that message.

Translate
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
Participant ,
Apr 19, 2018 Apr 19, 2018

Yeah, makes sense. Okay so I tried changing songURL in the first frame aswell.

var songURL:URLRequest;

var something="http://cast.loungefm.com.ua/terrace128?1372841071202.mp3";

songURL = new URLRequest(something);

Translate
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 ,
Apr 19, 2018 Apr 19, 2018

you probably made songURL local to a function.  it needs to be global to the timeline.

if you don't understand how to fix that, or you don't think that's the problem, show your frame 1 code.

Translate
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
Participant ,
Apr 19, 2018 Apr 19, 2018

Its global to the timeline( at least not inside a function)

stop();

import fl.controls.List;

import flash.net.URLRequest;

import flash.net.URLLoader;

import flash.events.Event;

list.width=stage.stageWidth;

list.height=600

list.x=(stage.stageWidth - list.width)/2;

list.y=0;

list.rowHeight=50;

var myFormat:TextFormat = new TextFormat();

myFormat.color="0xFFFFFF";

list.setRendererStyle("textFormat",myFormat);

var trackToPlay:String;

var pausePosition:int=0;

var songURL:URLRequest;

var something="http://cast.loungefm.com.ua/terrace128?1372841071202.mp3";

songURL = new URLRequest(something);

var i:uint;

var myXML:XML =new XML();

var XML_URL:String ="http://blogglista.no/something.xml";

var myXMLURL:URLRequest = new URLRequest(XML_URL);

var myLoader:URLLoader = new URLLoader(myXMLURL);

myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void{

myXML = XML(myLoader.data);

var firstSong:String = myXML..Song.songTitle[0];

var firstArtist:String = myXML..Song.songArtist[0];

var firstURL:String= myXML..Song.songURL[0];

songURL = new URLRequest(firstURL);

status_txt.text ="1. " +firstSong + "- "+firstArtist;

for each (var Song:XML in myXML..Song){

i++;

var songTitle:String = Song.songTitle.toString();

var songsongURL:String = Song.songURL.toString();

var songArtist:String=Song.songArtist.toString();

//songURL = Song.songURL.toString();

list.addItem({label: i+"."+songTitle+"-"+songArtist, songString: songsongURL,Artist: songArtist, songNum: i});

}

var myArray = new Array(0,0);

list.selectedIndices= myArray;

gotoAndStop(3);

}

Translate
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 ,
Apr 20, 2018 Apr 20, 2018

you didn't mention you changed your code and are now redefining songURL in xmlLoaded.  comment that line out and retest.

Translate
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
Participant ,
Apr 20, 2018 Apr 20, 2018

Yeah, sorry about that. I have been doing alot of tries here

So this is what ive done now:

//songURL = new URLRequest(firstURL);

Still the same error.

Translate
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 ,
Apr 20, 2018 Apr 20, 2018

show your code for the first and third frames.

Translate
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
Participant ,
Apr 20, 2018 Apr 20, 2018

frame 1:

stop();

import fl.controls.List;

import flash.net.URLRequest;

import flash.net.URLLoader;

import flash.events.Event;

list.width=stage.stageWidth;

list.height=600

list.x=(stage.stageWidth - list.width)/2;

list.y=0;

list.rowHeight=50;

var myFormat:TextFormat = new TextFormat();

myFormat.color="0xFFFFFF";

list.setRendererStyle("textFormat",myFormat);

var trackToPlay:String;

var pausePosition:int=0;

var songURL:URLRequest;

var something="http://cast.loungefm.com.ua/terrace128?1372841071202.mp3";

songURL = new URLRequest(something);

var i:uint;

var myXML:XML =new XML();

var XML_URL:String ="http://blogglista.no/something.xml";

var myXMLURL:URLRequest = new URLRequest(XML_URL);

var myLoader:URLLoader = new URLLoader(myXMLURL);

myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void{

myXML = XML(myLoader.data);

var firstSong:String = myXML..Song.songTitle[0];

var firstArtist:String = myXML..Song.songArtist[0];

var firstURL:String= myXML..Song.songURL[0];

//songURL = new URLRequest(firstURL);

status_txt.text ="1. " +firstSong + "- "+firstArtist;

for each (var Song:XML in myXML..Song){

i++;

var songTitle:String = Song.songTitle.toString();

var songsongURL:String = Song.songURL.toString();

var songArtist:String=Song.songArtist.toString();

//songURL = Song.songURL.toString();

list.addItem({label: i+"."+songTitle+"-"+songArtist, songString: songsongURL,Artist: songArtist, songNum: i});

}

var myArray = new Array(0,0);

list.selectedIndices= myArray;

gotoAndStop(3);

}

second:

import flash.net.URLRequest;

songURL = new URLRequest(trackToPlay);

third:

import flash.media.Sound;

import flash.media.SoundChannel;

import flash.media.SoundLoaderContext;

import flash.events.Event;

stop();

var snd:Sound=new Sound();

var channel:SoundChannel;

var context:SoundLoaderContext= new SoundLoaderContext(5000, true);

snd.load(songURL, context);

channel = snd.play(pausePosition);

list.addEventListener(Event.CHANGE, itemClick);

function itemClick(event:Event):void{

channel.stop();

status_txt.text = "Now Playing: " + event.target.selectedItem.label + ".mp3";

trackToPlay = event.target.selectedItem.songURL;

//trace(event.target.selectedItem);

trace(event.target.selectedItem.songString);

gotoAndPlay(2);

}

Translate
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 ,
Apr 20, 2018 Apr 20, 2018

copy and paste the error message and indicate the problematic line number.

Translate
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
Participant ,
Apr 20, 2018 Apr 20, 2018

I can run the code. When I push any of the 5 elements in my list, i get this error:

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

at flash.media::Sound/_load()

at flash.media::Sound/load()

at PlayingSoundFromXMLfileWeb_fla::MainTimeline/frame3()[PlayingSoundFromXMLfileWeb_fla.MainTimeline::frame3:12]

Translate
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 ,
Apr 21, 2018 Apr 21, 2018

what do you mean by "...push any...". are you clicking your list items????

if you are that's a completely different problem.

Translate
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
Participant ,
Apr 21, 2018 Apr 21, 2018

I can excecute the program, but when I click a channel in the list I get tht error. Yeah, that was what I first described. Should maybe have made that clearer, sorry

Translate
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 ,
Apr 21, 2018 Apr 21, 2018

in your 3rd frame, what's this show:

  1. function itemClick(event:Event):void{ 
  2.  
  3. channel.stop(); 
  4. status_txt.text = "Now Playing: " + event.target.selectedItem.label + ".mp3"; 
  5. trackToPlay = event.target.selectedItem.songURL; 
  6. trace('ttp:',trackToPlay);
  7. gotoAndPlay(2); 
  8. }

when that shows null or an empty string, fix your parsing in xmlLoaded in your first frame, or fix your xml to work with your parsing.

Translate
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
Participant ,
Apr 21, 2018 Apr 21, 2018

It showed null. You where right as always.

I changed the list addItem in frame 1 to this:

list.addItem({label: i+"."+songTitle, kgladMVP: songsongURL});

and changed the trackToPlay in frame3.

trackToPlay = event.target.selectedItem.kgladMVP;

Thank you very much kglad!

Translate
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 ,
Apr 22, 2018 Apr 22, 2018
LATEST

you're welcome.

Translate
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