Jump to content
Search Community

mp3 loader with xml not working

bonassus test
Moderator Tag

Recommended Posts

Ok what am I missing?

 

?xml version="1.0" encoding="iso-8859-1"?>
<data>
<LoaderMax name="sampleQueue" load="true">
  <MP3Loader  url="sound1.mp3" name="sound1" autoPlay="true"/>
</LoaderMax>
</data>

 

 

package{
import flash.display.Sprite;
import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
import flash.media.Sound;
public class TeacherCasting extends Sprite{
 var loader:XMLLoader;


 public function TeacherCasting()
 {
  LoaderMax.activate([MP3Loader]);
  loader = new XMLLoader("data.xml", {onComplete:completeHandler, estimatedBytes:50000});
  loader.load();
 }

 function completeHandler(event:LoaderEvent):void {
  trace("loaded");
 }

}
}

 

why isn't the completeHandler tracing anything?

Link to comment
Share on other sites

i don't know if you missed a character when copying and pasting, but the first line is malformed.

 

BAD

?xml version="1.0" encoding="iso-8859-1"?>

GOOD

<?xml version="1.0" encoding="iso-8859-1"?>

 

if that doesn't fix it please let me know

Link to comment
Share on other sites

Carl,

 

Thank you! I feel a bit silly but yes that was it. You saved me more hair pulling I thank you for that.

I now have a couple more question that i would very much apreiceate if you could once again direct your expert atention. my project now looks like this:

 

<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<LoaderMax name="queue_CoachZ" prependURLs="Casting_MP3s/" load="true">
	<MP3Loader  url="JeffGurner_CoachZ_02.mp3" name="JeffGurner_CoachZ_02" autoPlay="false"/>
	 <MP3Loader  url="ChrisPhillips_CoachZ_01.mp3" name="ChrisPhillips_CoachZ_01" autoPlay="false"/>
	  <MP3Loader  url="ChrisPhillips_CoachZ_05.mp3" name="ChrisPhillips_CoachZ_05" autoPlay="false"/>

</LoaderMax>
<LoaderMax name="queue_MrsWordy" prependURLs="Casting_MP3s/" load="true">
   <MP3Loader  url="CharityJames_MrsWordy_04.mp3" name="CharityJames_MrsWordy_04" autoPlay="false"/>
   <MP3Loader  url="CharityJames_MrsWordy_04.mp3" name="CharityJames_MrsWordy_05" autoPlay="false"/>
</LoaderMax>
</data>

 

I set two loaderMax objects in the xml that contain mp3Loaders

 

package{

import flash.display.Sprite;
import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
import flash.media.Sound;
import flash.events.MouseEvent;

public class TeacherCasting extends Sprite{
private	var queue:LoaderMax;
private var sound:Sound;
private var loader:XMLLoader;
private var coachZ_soundArray:Array;
	public function TeacherCasting(){

		LoaderMax.activate([MP3Loader]);
		loader = new XMLLoader("data.xml", {onComplete:completeHandler, estimatedBytes:50000});
		loader.load();
		btn1.addEventListener(MouseEvent.CLICK, toggleSound);

	}
	function completeHandler(event:LoaderEvent):void {
		trace(event.target + " is complete!");
		var queue_CoachZ:LoaderMax = LoaderMax.getLoader("queue_CoachZ");
		coachZ_soundArray = queue_CoachZ.content;

		trace(queue_CoachZ.name);
	}

	function toggleSound(event:MouseEvent):void {
		trace("click");
		coachZ_soundArray[2].soundPaused = !coachZ_soundArray[2].soundPaused;
	}
}
}

 

Problem 1, I am having trouble getting the name properties of the mp3 loaders. (this confuses me). I grab the loaderMax object named queue_CoachZ.

 

var queue_CoachZ:LoaderMax = LoaderMax.getLoader("queue_CoachZ");

And assign its content property to coachZ_soundArray

coachZ_soundArray = queue_CoachZ.content;

so now

trace(coachZ_soundArray[1]);

[object Sound] not MP3Loader? so trace(queue_CoachZ.name); doesn't work. how do i get to the name property of the MP3Loader for coachZ_soundArray[1]?

 

I want to put the sounds from each loaderMax in its own array and control the sounds through the array and have access to its loaders name property through the same array. Is this possible am I going about this the right way?

Thank you very much for your help.

Link to comment
Share on other sites

take a look at the following from the LoaderMax documentation:

 

 

content : *

[read-only] An array containing the content of each loader inside the LoaderMax

 

that's why you were getting [object Sound] from the content array.

 

 

 

 

 

getChildren( includeNested:Boolean = false, omitLoaderMaxes:Boolean = false ):Array

Returns an array of all child loaders inside the LoaderMax, optionally exposing more deeply nested instances as well (like loaders inside a child LoaderMax instance).

 

 

so if you want an array of all the child loaders of a LoaderMax, use the getChildren() method not the content property.

 

that should put you in the right direction.

 

-c

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...