|
-
Passing events out of a class
Hello all,
So I've created a custom class which makes use of a Sound object. The Sound object loads a sound from a URL, and I attach and event listener to it to see it when it finishes loading i.e. Event.Complete
MY question is this: how do I receive this event outside of the class? For instance, I want to be able to create an instance of my class somewhere else, load a sound and attach an event listener to my custom class that listens for the event thrown by the sound. Understandably, I don't want to make the sound object a public variable. So does anyone have any idea what to do?
THanks in advance,
j

my code is crap
-
The custom class can re-dispatch the event, or dispatch its own event as a response to the sound events. Other classes can then attach listeners to your custom class instance.
-
 Originally Posted by 5TonsOfFlax
The custom class can re-dispatch the event, or dispatch its own event as a response to the sound events. Other classes can then attach listeners to your custom class instance.
Sounds perfect! Do you know any good pages with info about redispatching events??
THanks,
j

my code is crap
-
Simply make sure your custom class is an IEventDispatcher (you can extend EventDispatcher if you need a baseclass) and call dispatchEvent with the same event.
There really isn't a lot to it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|