|
-
Creating a custom class which can return a custom event
Just as it says on the tin. I want to create a class which will do its work, and when it's done, generate an event back to my movie.
I want to use my custom class like this :
var test:Main = new Main()
test.onDone = function() {
// blah blah
}
Is there any sample classes which do this?
Im tearing my hair out over this!
-
half as fun, double the price
All you need to do is define onDone as a Function variable in Main
Code:
...
public var onDone:Function;
...
and then when it does the things you need, in whatever Main method that does those things (note this cannot be the constructor if a synchronous process since it will complete before you have a chance to define onDone), call it:
Code:
if (onDone) onDone();
In ActionScript 3, however, its more common to use EventDispatcher and addEventListwner/dispatchEvent
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
|