• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Event dispatching situation with SoundManager.as


I am using the tweener version of the class above (second link) and am having trouble attaching events such as...

addEventListener(ProgressEvent.PROGRESS, updateProgress);      
addEventListener(Event.COMPLETE, onComplete);

.. in an effort to bolt in a preloader functionality and some others like firing an event when a MP3 is done playing.

I have tried using the base Flash classes, and ran into issues with having multiple sound files queued up and the inability to reuse the sound object for new urls etc etc.  So I opted for a soundmanager class such as this, but am not having nearly equal issues with this.

I have tried to extend that class above with internal events that triggered methods in the class, but ran into issues with manipulating or targeting the functions I have on the timeline.

I have tried to attach the events to the calls to this function, perhaps my syntax is bunk:

EFFECTS.addExternalSound(effectPath, "effect", 0).addEventListener(ProgressEvent.PROGRESS, updateProgress);

Gives me:

1061: Call to a possibly undefined method addEventListener through a reference with static type Boolean.
1 Solution
taftmanAuthor Commented:
I may have solved my own issue, but I will post it for anyone else interested:

Adding this to the class, and the important listeners bolted directly to the snd objects as they are created privately:

                private function onComplete($name:String):void
			dispatchEvent(new Event("loadComplete")); 
		private function songEnded(e:Event):void{
			dispatchEvent(new Event("songEnded")); 
//** And these listeners setup directly after my MP3 is loaded into the object:
	EFFECTS.addEventListener("loadComplete", onComplete);
	EFFECTS.addEventListener("songEnded", playPause);
//** Effectively fires the functions as specified from the class.  I learned something new today!

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now