Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Event dispatching situation with SoundManager.as

Posted on 2009-07-01
1
Medium Priority
?
296 Views
Last Modified: 2013-11-11
http://evolve.reintroducing.com/2008/07/15/news/as3-soundmanager/
http://drawlogic.com/2009/01/16/as3-soundmanager-class-for-flash-updated-for-tweener/

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.
0
Comment
Question by:taftman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
taftman earned 0 total points
ID: 24757915
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

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question