This content has been marked as final. Show 13 replies
instead of creating a subclass of the eventdispatcher class, implement the ieventdispatcher class.
Thanks for this quick reply.
Hm, where is the difference?
Does EventDispatcher class have more(in this case too much) properties than IEventDispatcher class?
Hm I see now after one test in Flash...
Now, I've updated all these classes to use IEventDispatcher Interface...
When I test the movie I get an error:
1141: A class can only extend another class, not an interface.
So the MP3Player, SoundPlayer, LoaderXML classes are still using EventDispatcher...
i misled you. you can extend the eventdispatcher class.
you only need to implement the ieventdispatcher class if you need to inherit from another class (that doesn't inherit from the eventdispatcher class) and you also need event dispatching capabilities.
you don't extend an interface, you "implement" it. instead of using the "extends" keyword, use "implement".
Hm, I get a bunch of other errors, like:
1061: Call to a possibly undefined method addEventListener through a reference with static type com.mloncaric.media:MP3Player.
I think I'l need to create variable of type IEventDispatcher... or am I wrong?
you can just leave it the way you had it with your class extending the eventdispatcher class.
but if you implement the ieventdispatcher class, you need to create an eventdispatcher instance:
Thanks for your help.
I've changed the classes totally...
Now I don't have that problem anymore...
The problem was that every time I've clicked the play button, it created a new instance of SoundPlayer class.
Now I have only one instance of the SoundPlayer class, and then I'm just calling its methods like play, pause, stop, volume, pan, etc...
But here is the new problem:
Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
I heard somewhere that Sound Object can have only one song in it, for every other it needs a new instance of Sound object...
I've found that in Flash docs:
Once load() is called on a Sound object, you can't later load a different sound file into that Sound object. To load a different sound file, create a new Sound object.
Well here is the updated version of SoundPlayer class...
It might help you a little bit...
yes, the compiler will throw an error is the load method is applied more than once to any one sound instance.
Hm and how can I avoid that?
When I delete the sound object, it throws me an error because its the fixed variable.
I don't know what to do:)
create a different sound instance each time you need to load a new file file.