Answered
custom component - dynamic instances
Hi - I've just finished creating a custom component. During
development I've been dragging the component to the stage in the
ide and it has been working fine. However, now I've come to try to
create it dynamically eg
var newinstance:Mycomponent = new Mycomponent();
I've got a problem.
Access to all my methods disappears including the addeventlistener method. Flash moans that there is no method named addEventListener(...) etc.
If I put my component definition in the first frame and the method calls and event listener stuff in the second frame, then flash no longer complains and I can trace all the properties etc but the events aren't fired.
So it seems there are two problems. The first I think has to do with #initclip stuff in component movieclip. In there I'm calling this.registerClass(...) as instructed but I have a feeling from what I've read that there should be something else going on in there to initialise the component when it's dynamically created. The second is something to do with eventdispatching, how is it that something so simple can take so long to figure out. I must be thick.
Any help would be greatly appreciated.
btw I've tried using createClassComponent and attachmovie with the same results.
var newinstance:Mycomponent = new Mycomponent();
I've got a problem.
Access to all my methods disappears including the addeventlistener method. Flash moans that there is no method named addEventListener(...) etc.
If I put my component definition in the first frame and the method calls and event listener stuff in the second frame, then flash no longer complains and I can trace all the properties etc but the events aren't fired.
So it seems there are two problems. The first I think has to do with #initclip stuff in component movieclip. In there I'm calling this.registerClass(...) as instructed but I have a feeling from what I've read that there should be something else going on in there to initialise the component when it's dynamically created. The second is something to do with eventdispatching, how is it that something so simple can take so long to figure out. I must be thick.
Any help would be greatly appreciated.
btw I've tried using createClassComponent and attachmovie with the same results.