Re: [Flashcoders] The issue of "parent" in AS3
I must disagree with this. Typing to Object will give you extra problems. You will not get code hinting and are more likely to make typeo's. It also is much more vulnerable to runtime errors. As for the original message, I would encourage you not to call any non-DisplayObject methods in the parent. This will tightly couple the child to a specific parent, making it useless on other parents. If you want to pass information to another object you can use the event system and dispatch an event. Another options is to give the child a property which is typed to an interface. This property should (in your case) be set to reference the parent and will give you the ability to call that specific method. On top of that, the child can be used with another implementation of the logic you are trying to call. Greetz Erik On 5/15/08, Sy Iridium <[EMAIL PROTECTED]> wrote: > > Hi, > don't know if my way is "cleaner" but it is certainly more general because > if you change the parent class you don't need to "find and replace" all > type-casting of the previous class with new class. My solution to this is > to > type-cast the parent class to Object class. It is dynamic class so you can > use any methods you have added to your class without restrictions. Hope it > helps. > > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] The issue of "parent" in AS3
Hi, don't know if my way is "cleaner" but it is certainly more general because if you change the parent class you don't need to "find and replace" all type-casting of the previous class with new class. My solution to this is to type-cast the parent class to Object class. It is dynamic class so you can use any methods you have added to your class without restrictions. Hope it helps. 2008/5/15 Johan Nyberg <[EMAIL PROTECTED]>: > Anybody knows if it's bad practice to type-cast the parent-property to the > class of the parent? > > Since parent is a property of the DisplayObject class, you can only > reference properties and methods of that class directly through the > parent-property. > > If you want to access other properties or methods, you have to type-cast > parent to the specific class. > > If you have some other "cleaner" ways of doing this it would be greatly > appreciated! > > Regards, > > Johan Nyberg > Designer and web developer > > [EMAIL PROTECTED] > 08 - 50 00 24 30 > 070 - 407 83 00 > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] The issue of "parent" in AS3
Anybody knows if it's bad practice to type-cast the parent-property to the class of the parent? Since parent is a property of the DisplayObject class, you can only reference properties and methods of that class directly through the parent-property. If you want to access other properties or methods, you have to type- cast parent to the specific class. If you have some other "cleaner" ways of doing this it would be greatly appreciated! Regards, Johan Nyberg Designer and web developer [EMAIL PROTECTED] 08 - 50 00 24 30 070 - 407 83 00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders